Make the tests more robust.

This commit is contained in:
Jonathan Lange
2010-10-31 14:21:32 -04:00
parent d921f00c4c
commit 15ed60cb55

View File

@@ -26,12 +26,19 @@ class TestTryImport(TestCase):
self.assertThat(result, Is(os))
def test_existing_submodule(self):
# try_import('thing', foo) imports 'thing' and returns it if it's a
# module that exists.
# try_import('thing.another', foo) imports 'thing' and returns it if
# it's a module that exists.
result = try_import('os.path', object())
import os
self.assertThat(result, Is(os.path))
def try_nonexistent_submodule(self):
# try_import('thing.another', foo) imports 'thing' and returns foo if
# 'another' doesn't exist.
marker = object()
result = try_import('os.doesntexist', marker)
self.assertThat(result, Is(marker))
def test_suite():
from unittest import TestLoader