assertlib
Advanced tools
+32
-26
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
| __author__ = "Anthony Long" | ||
| """assertlib is a library of standalone assertion methods. | ||
@@ -23,3 +24,3 @@ | ||
| else: | ||
| raise AssertionError("%s is not equal to %s" % (x, y)) | ||
| raise AssertionError("{} is not equal to {}".format(x, y)) | ||
@@ -37,5 +38,4 @@ | ||
| if not len(str(format(a)).partition('.')[2]) == int(amount): | ||
| raise AssertionError("{a} does not have {amount} precision.".format( | ||
| str(a), str(amount)) | ||
| ) | ||
| raise AssertionError("{} does not have {} precision.".format( | ||
| str(a), str(amount))) | ||
@@ -51,3 +51,3 @@ | ||
| if a == b: | ||
| raise AssertionError("%s did not equal %s." % (a, b)) | ||
| raise AssertionError("{} did not equal {}.".format(a, b)) | ||
@@ -65,3 +65,3 @@ | ||
| if not bool(x): | ||
| raise AssertionError("{x} did not evaluate to True.".format(x)) | ||
| raise AssertionError("{} did not evaluate to True.".format(x)) | ||
@@ -77,3 +77,3 @@ | ||
| if bool(x): | ||
| raise AssertionError("%s did not evaluate to False." % x) | ||
| raise AssertionError("{} did not evaluate to False.".format(x)) | ||
@@ -96,3 +96,3 @@ | ||
| if a is not b: | ||
| raise AssertionError("{a} is not {b}".format(a, b)) | ||
| raise AssertionError("{} is not {}".format(a, b)) | ||
@@ -107,3 +107,3 @@ | ||
| if a is b: | ||
| raise AssertionError("{a} is {b}".format(a, b)) | ||
| raise AssertionError("{} is {}".format(a, b)) | ||
@@ -118,3 +118,5 @@ | ||
| if not isinstance(x, instanceof): | ||
| raise AssertionError("{} is not an instance of {}".format(x, instanceof)) | ||
| raise AssertionError("{} is not an instance of {}".format( | ||
| x, instanceof) | ||
| ) | ||
@@ -129,3 +131,3 @@ | ||
| if isinstance(x, instanceof): | ||
| raise AssertionError("{x} is an instance of {instanceof}".format(x, instanceof)) | ||
| raise AssertionError("{} is an instance of {}".format(x, instanceof)) | ||
@@ -152,7 +154,7 @@ | ||
| raise AssertionError( | ||
| '%s != %s within %s delta' % (a, b, epsilon)) | ||
| '{} != {} within {} delta'.format(a, b, epsilon)) | ||
| else: | ||
| if round(abs(b - a), places) == 0: | ||
| raise AssertionError( | ||
| '%s != %s within %s places' % (a, b, places)) | ||
| '{} != {} within {} places'.format(a, b, places)) | ||
@@ -166,6 +168,6 @@ | ||
| <http://docs.python.org/tutorial/floatingpoint.html>`_. | ||
| >>> assertNotAlmostEqual(1.1, 1.12, places=5) | ||
| >>> assertNotAlmostEqual(1.1, 1.11, epsilon=5) | ||
| Example: | ||
| >>> assertNotAlmostEqual(1.1, 1.12, places=5) | ||
| >>> assertNotAlmostEqual(1.1, 1.11, epsilon=5) | ||
| """ | ||
@@ -175,13 +177,13 @@ if a != b: | ||
| if a == b: | ||
| raise AssertionError('%s == %s' % (a, b)) | ||
| raise AssertionError('{} == {}'.format(a, b)) | ||
| if places and epsilon: | ||
| raise TypeError("specify delta or places not both") | ||
| raise TypeError("Specify delta or places, not both.") | ||
| if epsilon is not None: | ||
| if abs(a - b) >= epsilon: | ||
| raise AssertionError( | ||
| '%s == %s within %s delta' % (a, b, epsilon)) | ||
| '{} == {} within {} delta'.format(a, b, epsilon)) | ||
| else: | ||
| if round(abs(b - a), places) != 0: | ||
| raise AssertionError( | ||
| '%s == %s within %s places' % (a, b, places)) | ||
| '{} == {} within {} places'.format(a, b, places)) | ||
@@ -192,10 +194,14 @@ | ||
| Example: | ||
| >>> assertSequenceEqual([1,2,3], [1,2,3]) | ||
| """ | ||
| if assert_seq_types and type(seq1) != type(seq2): | ||
| raise TypeError("type %s != type %s" % (type(seq1), type(seq2))) | ||
| raise TypeError("type {} != type {}".format(type(seq1), type(seq2))) | ||
| if len(seq1) != len(seq2): | ||
| raise AssertionError("len(%s) of seq1 != len(%s) of seq2" % (len(seq1), len(seq2))) | ||
| raise AssertionError( | ||
| "len({}) of seq1 != len({}) of seq2".format( | ||
| len(seq1), len(seq2)) | ||
| ) | ||
| if not all(a == b for a, b in itertools.izip(seq1, seq2)): | ||
| raise AssertionError("%s is not equal to %s" % (seq1, seq2)) | ||
| raise AssertionError("{} is not equal to {}".format(seq1, seq2)) | ||
@@ -210,5 +216,5 @@ | ||
| if assert_seq_types and type(seq1) == type(seq2): | ||
| raise TypeError("type %s == type %s" % (type(seq1), type(seq2))) | ||
| raise TypeError("type {} == type {}".format(type(seq1), type(seq2))) | ||
| if all(a != b for a, b in itertools.izip(seq1, seq2)): | ||
| raise AssertionError("%s is equal to %s" % (seq1, seq2)) | ||
| raise AssertionError("{} is equal to {}".format(seq1, seq2)) | ||
@@ -215,0 +221,0 @@ |
+1
-1
| Metadata-Version: 1.1 | ||
| Name: assertlib | ||
| Version: 0.3 | ||
| Version: 0.3.1 | ||
| Summary: assertlib is a standalone library of assertion methods. | ||
@@ -5,0 +5,0 @@ Home-page: http://github.com/antlong/assertlib |
+1
-1
@@ -7,3 +7,3 @@ #!/usr/bin/env python | ||
| name='assertlib', | ||
| version='0.3', | ||
| version='0.3.1', | ||
| description='assertlib is a standalone library of assertion methods.', | ||
@@ -10,0 +10,0 @@ keywords='assert assertions validation valid data test testing \ |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
10727
1.38%236
3.06%