Change assets naming method (#199)
* added assets name hashing option * from command line option to config option * new naming strategy * fix * Flake8 issues fixed * more Flake8 issues fixed
This commit is contained in:
parent
703a5ccdea
commit
27b6e77ab1
|
@ -145,12 +145,14 @@ class HTMLReport(object):
|
|||
|
||||
def create_asset(self, content, extra_index,
|
||||
test_index, file_extension, mode='w'):
|
||||
|
||||
hash_key = ''.join([self.test_id, str(extra_index),
|
||||
str(test_index)]).encode('utf-8')
|
||||
str(test_index)])
|
||||
hash_generator = hashlib.md5()
|
||||
hash_generator.update(hash_key)
|
||||
asset_file_name = '{0}.{1}'.format(hash_generator.hexdigest(),
|
||||
file_extension)
|
||||
hash_generator.update(hash_key.encode('utf-8'))
|
||||
asset_file_name = '{0}_{1}.{2}'.format(hash_key,
|
||||
hash_generator.hexdigest(),
|
||||
file_extension)
|
||||
asset_path = os.path.join(os.path.dirname(self.logfile),
|
||||
'assets', asset_file_name)
|
||||
if not os.path.exists(os.path.dirname(asset_path)):
|
||||
|
|
|
@ -383,12 +383,12 @@ class TestHTML:
|
|||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
hash_key = ('test_extra_text_separated.py::'
|
||||
'test_pass00').encode('utf-8')
|
||||
'test_pass00')
|
||||
hash_generator = hashlib.md5()
|
||||
hash_generator.update(hash_key)
|
||||
hash_generator.update(hash_key.encode('utf-8'))
|
||||
assert result.ret == 0
|
||||
src = '{0}/{1}'.format('assets', '{0}.txt'.
|
||||
format(hash_generator.hexdigest()))
|
||||
src = '{0}/{1}'.format('assets', '{0}_{1}.txt'.
|
||||
format(hash_key, hash_generator.hexdigest()))
|
||||
link = ('<a class="text" href="{0}" target="_blank">'.format(src))
|
||||
assert link in html
|
||||
assert os.path.exists(src)
|
||||
|
@ -412,13 +412,12 @@ class TestHTML:
|
|||
""".format(extra_type, content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
hash_key = ('test_extra_image_separated.py::'
|
||||
'test_pass00').encode('utf-8')
|
||||
hash_key = 'test_extra_image_separated.py::test_pass00'
|
||||
hash_generator = hashlib.md5()
|
||||
hash_generator.update(hash_key)
|
||||
hash_generator.update(hash_key.encode('utf-8'))
|
||||
assert result.ret == 0
|
||||
src = '{0}/{1}'.format('assets', '{0}.{1}'.
|
||||
format(hash_generator.hexdigest(),
|
||||
src = '{0}/{1}'.format('assets', '{0}_{1}.{2}'.
|
||||
format(hash_key, hash_generator.hexdigest(),
|
||||
file_extension))
|
||||
link = ('<a class="image" href="{0}" target="_blank">'.format(src))
|
||||
assert link in html
|
||||
|
@ -451,11 +450,12 @@ class TestHTML:
|
|||
|
||||
for i in range(1, 4):
|
||||
hash_key = ('test_extra_image_separated_rerun.py::'
|
||||
'test_fail0{0}'.format(i)).encode('utf-8')
|
||||
'test_fail0{0}'.format(i))
|
||||
hash_generator = hashlib.md5()
|
||||
hash_generator.update(hash_key)
|
||||
src = 'assets/{0}.{1}'.format(hash_generator.hexdigest(),
|
||||
file_extension)
|
||||
hash_generator.update(hash_key.encode('utf-8'))
|
||||
src = 'assets/{0}_{1}.{2}'.format(hash_key,
|
||||
hash_generator.hexdigest(),
|
||||
file_extension)
|
||||
link = ('<a class="image" href="{0}" target="_blank">'.format(src))
|
||||
assert result.ret
|
||||
assert link in html
|
||||
|
|
Loading…
Reference in New Issue