Skip to content
Merged
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
frenzymadness committed May 12, 2020
commit 97b057edc7165492522ba0226cd40296c51c5ec5
9 changes: 8 additions & 1 deletion Lib/test/test_compileall.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,12 @@ def test_hardlink_deduplication_same_bytecode(self):

pycs = {}
for opt_level in opt_combination:
# We need this because importlib.util.cache_from_source
# produces different results when called with
# optimization=0 and without optimization
optimization_kwarg = {"optimization": opt_level} if opt_level > 0 else {}
pycs[opt_level] = importlib.util.cache_from_source(
simple_script, optimization=opt_level
simple_script, **optimization_kwarg
)

compileall.compile_dir(
Expand All @@ -415,6 +419,9 @@ def test_hardlink_deduplication_same_bytecode(self):
for pair in itertools.combinations(opt_combination, 2):
self.assertFalse(self.is_hardlink(pycs[pair[0]], pycs[pair[1]]))

for pyc_file in pycs.values():
os.unlink(pyc_file)

def test_hardlink_deduplication_different_bytecode_all_opt(self):
# "'''string'''\nassert 1" produces a different bytecode for
# all optimization levels
Expand Down