8000 Don't use assert which gets optimized away · matplotlib/matplotlib@871a62a · GitHub
[go: up one dir, main page]

Skip to content

Commit 871a62a

Browse files
committed
Don't use assert which gets optimized away
with python -O
1 parent 0083367 commit 871a62a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/matplotlib/tests/test_cache.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import stat
1111
import tempfile
1212

13-
from nose.tools import raises
13+
from nose.tools import raises, assert_true, assert_false
1414

1515
from matplotlib import cbook
1616
from matplotlib.testing.conversion_cache import ConversionCache, CacheError
@@ -28,22 +28,22 @@ def intmp(f):
2828
with open(intmp('fake.svg'), 'w') as svg:
2929
svg.write('this pretends to be an svg file')
3030

31-
assert not cache.get(intmp('fake.pdf'), intmp('fakepdf.png'))
32-
assert not cache.get(intmp('fake.svg'), intmp('fakesvg.png'))
31+
assert_false(cache.get(intmp('fake.pdf'), intmp('fakepdf.png')))
32+
assert_false(cache.get(intmp('fake.svg'), intmp('fakesvg.png')))
3333

3434
with open(intmp('fakepdf.png'), 'w') as png:
3535
png.write('generated from the pdf file')
3636
cache.put(intmp('fake.pdf'), intmp('fakepdf.png'))
37-
assert cache.get(intmp('fake.pdf'), intmp('copypdf.png'))
37+
assert_true(cache.get(intmp('fake.pdf'), intmp('copypdf.png')))
3838
with open(intmp('copypdf.png'), 'r') as copy:
39-
assert copy.read() == 'generated from the pdf file'
39+
assert_true(copy.read() == 'generated from the pdf file')
4040

4141
with open(intmp('fakesvg.png'), 'w') as png:
4242
png.write('generated from the svg file')
4343
cache.put(intmp('fake.svg'), intmp('fakesvg.png'))
44-
assert cache.get(intmp('fake.svg'), intmp('copysvg.png'))
44+
assert_true(cache.get(intmp('fake.svg'), intmp('copysvg.png')))
4545
with open(intmp('copysvg.png'), 'r') as copy:
46-
assert copy.read() == 'generated from the svg file'
46+
assert_true(copy.read() == 'generated from the svg file')
4747
finally:
4848
shutil.rmtree(tmpdir)
4949

@@ -62,23 +62,23 @@ def intmp(*f):
6262
os.utime(filename, (i*1000, i*1000))
6363

6464
cache.expire()
65-
assert not os.path.exists(intmp('cache', 'file0.png'))
66-
assert not os.path.exists(intmp('cache', 'file1.png'))
67-
assert not os.path.exists(intmp('cache', 'file2.png'))
68-
assert os.path.exists(intmp('cache', 'file3.png'))
69-
assert os.path.exists(intmp('cache', 'file4.png'))
65+
assert_false(os.path.exists(intmp('cache', 'file0.png')))
66+
assert_false(os.path.exists(intmp('cache', 'file1.png')))
67+
assert_false(os.path.exists(intmp('cache', 'file2.png')))
68+
assert_true(os.path.exists(intmp('cache', 'file3.png')))
69+
assert_true(os.path.exists(intmp('cache', 'file4.png')))
7070

7171
with open(intmp('cache', 'onemore.png'), 'w') as f:
7272
f.write('x' * 11)
7373
os.utime(intmp('cache', 'onemore.png'), (5000, 5000))
7474

7575
cache.expire()
76-
assert not os.path.exists(intmp('cache', 'file0.png'))
77-
assert not os.path.exists(intmp('cache', 'file1.png'))
78-
assert not os.path.exists(intmp('cache', 'file2.png'))
79-
assert not os.path.exists(intmp('cache', 'file3.png'))
80-
assert not os.path.exists(intmp('cache', 'file4.png'))
81-
assert not os.path.exists(intmp('cache', 'onemore.png'))
76+
assert_false(os.path.exists(intmp('cache', 'file0.png')))
77+
assert_false(os.path.exists(intmp('cache', 'file1.png')))
78+
assert_false(os.path.exists(intmp('cache', 'file2.png')))
79+
assert_false(os.path.exists(intmp('cache', 'file3.png')))
80+
assert_false(os.path.exists(intmp('cache', 'file4.png')))
81+
assert_false(os.path.exists(intmp('cache', 'onemore.png')))
8282

8383
finally:
8484
shutil.rmtree(tmpdir)

0 commit comments

Comments
 (0)
0