-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake8-AAE-tests.py
35 lines (28 loc) · 1.24 KB
/
flake8-AAE-tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""A module as test dummy for flake8-assertAlmostEqual."""
import unittest
class TestSelfAssertEqualDetection(unittest.TestCase):
"""Dummy for flake8-assertAlmostEqual."""
def setUp(self):
"""Set up."""
self.my_result = 5.0473
def test_detection(self):
"""Detect flake8-assertAlmostEqual violoations."""
# Simple one-liners:
self.assertAlmostEqual(5.05, round(self.my_result, 2))
self.assertEqual(round(self.my_result, 3), 5.047)
# Comments (shouldn't be detected):
# self.assertAlmostEqual(5.05, round(self.my_result, 2))
# self.assertEqual(round(self.my_result, 3), 5.047)
# Two-liners:
self.assertAlmostEqual(5.05,
round(self.my_result, 2))
self.assertEqual(
round(self.my_result, 3), 5.047)
# NOQAs:
# This shouldn't be detected as AAE100, but has a trailing whitespace!
self.assertAlmostEqual(5.05, round(self.my_result, 2)) # noqa: AAE100
# This should be detected, because it's AAE110:
self.assertEqual(round(self.my_result, 3), 5.047) # noqa: AAE100
if __name__ == '__main__':
runner = unittest.TextTestRunner(verbosity=2)
unittest.main(testRunner=runner)