assertlib
Advanced tools
| Metadata-Version: 1.1 | ||
| Name: assertlib | ||
| Version: 0.1 | ||
| Version: 0.2 | ||
| Summary: UNKNOWN | ||
@@ -5,0 +5,0 @@ Home-page: http://www.antlong.com/ |
+29
-20
| import itertools | ||
| def assertEqual(object, control): | ||
| def assertEqual(x, y): | ||
| """ | ||
| This method asserts that an object is equal to a control. | ||
| >>> assertEqual(1, 1) | ||
| >>> assertEqual(str(1), '1') | ||
| """ | ||
| if not object == control: | ||
| raise AssertionError("%s is not equal to %s" % (object, control)) | ||
| if not x == y: | ||
| raise AssertionError("%s is not equal to %s" % (x, y)) | ||
| def assertPrecision(object, amount): | ||
| """ | ||
| Asserts an object has x amount of precision. | ||
| def assertPrecision(object, control): | ||
| """ | ||
| This method will assert an object is precise to your control. | ||
| >>> assertPrecision(1.111, 3) | ||
| """ | ||
| if not len(str(object).partition('.')[2]) == control: | ||
| raise AssertionError("") | ||
| if not len(str(format(object)).partition('.')[2]) == int(amount): | ||
| raise AssertionError("%s does not have %s precision." % (str(object), str(amount))) | ||
| def assertEquals(object, control): | ||
| def assertEquals(x, y): | ||
| """ | ||
| This method asserts that an object is equal to a control. | ||
| This method asserts that x is equal to y. | ||
@@ -32,8 +31,8 @@ >>> assertEquals(1, 1) | ||
| """ | ||
| assertEqual(object, control) | ||
| assertEqual(x, y) | ||
| def assertNotEqual(object, control): | ||
| def assertNotEqual(x, y): | ||
| """ | ||
| This method asserts that an object is not equal to a control. | ||
| This method asserts that x is not equal to y. | ||
@@ -43,4 +42,4 @@ >>> assertNotEqual(1, '1') | ||
| """ | ||
| if object == control: | ||
| raise AssertionError("%s did not equal %s." % (object, control)) | ||
| if x == y: | ||
| raise AssertionError("%s did not equal %s." % (x, y)) | ||
@@ -71,3 +70,3 @@ | ||
| This method asserts that an object or expression evaluates to False. | ||
| >>> assertFalse(False) | ||
@@ -82,3 +81,3 @@ """ | ||
| This method asserts that an object evaluates to a control. | ||
| >>> def x(): | ||
@@ -135,4 +134,4 @@ ... return 1 | ||
| '%s != %s within %s places' % (first, second, places)) | ||
| def assertNotAlmostEqual(first, second, places=None, epsilon=None): | ||
@@ -180,4 +179,14 @@ """ | ||
| def assertEither(control, x, y): | ||
| """Assert that x evaluates to either y or z.""" | ||
| if control != this or control != z: | ||
| raise AssertionError("{0} is neither {1} or {2}".format(control,x,y)) | ||
| def assertNotEither(control, x, y): | ||
| """Assert that x evaluates to either y or z.""" | ||
| if control == this or control == z: | ||
| raise AssertionError("{0} is neither {1} or {2}".format(control,x,y)) | ||
| if __name__ == "__main__": | ||
| import doctest | ||
| doctest.testmod() |
+1
-1
| Metadata-Version: 1.1 | ||
| Name: assertlib | ||
| Version: 0.1 | ||
| Version: 0.2 | ||
| Summary: UNKNOWN | ||
@@ -5,0 +5,0 @@ Home-page: http://www.antlong.com/ |
+1
-1
@@ -5,3 +5,3 @@ import setuptools | ||
| name='assertlib', | ||
| version='0.1', | ||
| version='0.2', | ||
| requires=['functools'], | ||
@@ -8,0 +8,0 @@ install_requires=['distribute'], |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
6642
5.05%153
5.52%