import pytest
import base64
log = { 'a':'none', 'b':'none', 'sum':'none' }
log_html = 'none'
log_img = 'none'
log_img_url = 'none'
def set_global_var(a='none',b='none',sum_='none',html='none',img='none',img_url='none'):
global log, log_html, log_img, log_img_url
log = { 'a': a, 'b': b, 'sum': sum_ }
log_html = html
log_img = img
log_img_url = img_url
@pytest.fixture(scope="function", autouse=True)
def default_global_var():
set_global_var()
def test_default():
''' '''
assert True
def test_1():
''' '''
a, b = 2, 2
sum_ = a + b
set_global_var( a = a, b = b, sum_ = sum_ )
assert sum_ == 4
def test_2():
''' '''
a, b = 3, 3
sum_ = a + b
html = '''
<p>
<table border="3" width="100%">
<tbody>
<tr>
<td bgcolor="#D3D3D3"><font color="black"><strong>a</strong></font></td>
<td bgcolor="#D3D3D3"><font color="black"><strong>b</strong></font></td>
<td bgcolor="#D3D3D3"><font color="black"><strong>sum</strong></font></td>
</tr>
<tr>
<td><font color="black">{0}</font></td>
<td><font color="black">{1}</font></td>
<td><font color="black">{2}</font></td>
</tr>
</tbody>
</table>
</p>
'''.format( a, b, sum_ )
set_global_var( a = a, b = b, sum_ = sum_, html = html )
assert sum_ == 6
def test_3():
''' '''
a, b = 4, 4
sum_ = a + b
image = open('test-1.jpg', 'rb')
image_read = image.read()
img = base64.encodebytes( image_read ).decode("utf-8")
set_global_var( a = a, b = b, sum_ = sum_, img = img )
assert sum_ == 8
def test_4():
''' '''
a, b = 5, 5
sum_ = a + b
img_url = 'test-2.jpg'
set_global_var( a = a, b = b, sum_ = sum_, img_url = img_url )
assert sum_ == 10
def test_5():
''' '''
a, b = 5, 1
sum_ = a + b
html = '<h1> HTML-</h1>'
image = open('test-1.jpg', 'rb')
image_read = image.read()
img = base64.encodebytes( image_read ).decode("utf-8")
img_url = 'test-2.jpg'
set_global_var( a = a, b = b, sum_ = sum_, html = html, img = img, img_url = img_url )
print (' ...')
assert sum_ == 6
@pytest.mark.parametrize("test_a, test_b, test_sum", [(1,2,3), (2,3,5), (4,5,8)])
def test_6(test_a, test_b, test_sum):
''' '''
a, b = test_a, test_b
sum_ = a + b
set_global_var( a = a, b = b, sum_ = sum_ )
assert sum_ == test_sum