diff options
author | Joffrey F <joffrey@docker.com> | 2015-09-23 17:42:29 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2015-10-21 16:02:09 -0700 |
commit | 93a296fb0448d9fccdf9f40f7a9996f49ea22c48 (patch) | |
tree | 633371cbdf88435664b530c4ca835c4929d92274 /tests/base.py | |
parent | 5a1c7ed8bf0ac9a3914de7c80c1c29c13f6a62ea (diff) | |
download | docker-py-reorganize_tests.tar.gz |
Reorganize test directoriesreorganize_tests
More clearly separate unit and integration tests
Allow splitting into multiple files
Cleaner
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/base.py')
-rw-r--r-- | tests/base.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/base.py b/tests/base.py index 51b2300..a2c01fc 100644 --- a/tests/base.py +++ b/tests/base.py @@ -21,3 +21,28 @@ def requires_api_version(version): ), reason="API version is too low (< {0})".format(version) ) + + +class Cleanup(object): + if sys.version_info < (2, 7): + # Provide a basic implementation of addCleanup for Python < 2.7 + def __init__(self, *args, **kwargs): + super(Cleanup, self).__init__(*args, **kwargs) + self._cleanups = [] + + def tearDown(self): + super(Cleanup, self).tearDown() + ok = True + while self._cleanups: + fn, args, kwargs = self._cleanups.pop(-1) + try: + fn(*args, **kwargs) + except KeyboardInterrupt: + raise + except: + ok = False + if not ok: + raise + + def addCleanup(self, function, *args, **kwargs): + self._cleanups.append((function, args, kwargs)) |