Exemplo n.º 1
0
    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        obj = datetime(2000, 1, 1)
        self.assertFalse(hasattr(obj, '__module__'))
        self.assertEqual(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, '__module__'))
        self.assertEqual(locator.get_object_directory(None), None)
Exemplo n.º 2
0
    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        obj = datetime(2000, 1, 1)
        self.assertFalse(hasattr(obj, "__module__"))
        self.assertEquals(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, "__module__"))
        self.assertEquals(locator.get_object_directory(None), None)
Exemplo n.º 3
0
    def test_get_object_directory(self):
        locator = Locator()

        obj = SayHello()
        actual = locator.get_object_directory(obj)

        self.assertEquals(actual, os.path.abspath(DATA_DIR))
Exemplo n.º 4
0
    def test_get_object_directory(self):
        locator = Locator()

        obj = SayHello()
        actual = locator.get_object_directory(obj)

        self._assert_paths(actual, DATA_DIR)
Exemplo n.º 5
0
    def test_get_object_directory(self):
        locator = Locator()

        obj = SayHello()
        actual = locator.get_object_directory(obj)

        self._assert_paths(actual, DATA_DIR)
Exemplo n.º 6
0
    def test_get_object_directory(self):
        locator = Locator()

        reader = Reader()
        actual = locator.get_object_directory(reader)

        expected = os.path.join(os.path.dirname(__file__), os.pardir, 'pystache')

        self.assertEquals(os.path.normpath(actual), os.path.normpath(expected))
Exemplo n.º 7
0
    def test_find_object__none_object_directory(self):
        locator = Locator()

        obj = None
        self.assertEquals(None, locator.get_object_directory(obj))

        actual = locator.find_object(search_dirs=[DATA_DIR], obj=obj, file_name="say_hello.mustache")
        expected = os.path.join(DATA_DIR, "say_hello.mustache")

        self.assertEquals(actual, expected)
Exemplo n.º 8
0
    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        # Previously, we used a genuine object -- a datetime instance --
        # because datetime instances did not have the __module__ attribute
        # in CPython.  See, for example--
        #
        #   http://bugs.python.org/issue15223
        #
        # However, since datetime instances do have the __module__ attribute
        # in PyPy, we needed to switch to something else once we added
        # support for PyPi.  This was so that our test runs would pass
        # in all systems.
        obj = "abc"
        self.assertFalse(hasattr(obj, '__module__'))
        self.assertEqual(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, '__module__'))
        self.assertEqual(locator.get_object_directory(None), None)
Exemplo n.º 9
0
    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        # Previously, we used a genuine object -- a datetime instance --
        # because datetime instances did not have the __module__ attribute
        # in CPython.  See, for example--
        #
        #   http://bugs.python.org/issue15223
        #
        # However, since datetime instances do have the __module__ attribute
        # in PyPy, we needed to switch to something else once we added
        # support for PyPi.  This was so that our test runs would pass
        # in all systems.
        obj = "abc"
        self.assertFalse(hasattr(obj, '__module__'))
        self.assertEqual(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, '__module__'))
        self.assertEqual(locator.get_object_directory(None), None)
Exemplo n.º 10
0
    def test_find_object__none_object_directory(self):
        locator = Locator()

        obj = None
        self.assertEqual(None, locator.get_object_directory(obj))

        actual = locator.find_object(search_dirs=[DATA_DIR], obj=obj, file_name='say_hello.mustache')
        expected = os.path.join(DATA_DIR, 'say_hello.mustache')

        self.assertEqual(actual, expected)
Exemplo n.º 11
0
    def test_get_object_directory(self):
        locator = Locator()

        reader = Reader()
        actual = locator.get_object_directory(reader)

        expected = os.path.join(os.path.dirname(__file__), os.pardir,
                                'pystache')

        self.assertEquals(os.path.normpath(actual), os.path.normpath(expected))