예제 #1
0
 def test__module_object(self):
     filename = os.path.join(root_path(),
                             'applications/app1/tests/test_module_a.py'
                             )
     test_file = File(filename, root_path())
     test_file.parse()
     expect = Module(os.path.join(root_path(),
                     'applications/app1/modules/module_a.py'),
                     root_path())
     self.assertEqual(test_file.module_object(), expect)
     return
예제 #2
0
    def test__relative_module(self):
        filename = os.path.join(root_path(),
                                'applications/app1/tests/test_module_a.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = 'applications.app1.tests.test_module_a'
        self.assertEqual(test_file.relative_module(), expect)

        # Test parse with script with sub directory

        filename = os.path.join(root_path(),
                                'applications/app2/tests/adir/test_module_d.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = 'applications.app2.tests.adir.test_module_d'
        self.assertEqual(test_file.relative_module(), expect)
        return
예제 #3
0
    def test__import_line(self):
        filename = os.path.join(root_path(),
                                'applications/app1/tests/test_module_a.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = \
            'from applications.app1.modules.module_a import ClassA, ClassAA'
        self.assertEqual(test_file.import_line(), expect)

        # Test parse with script with sub directory

        filename = os.path.join(root_path(),
                                'applications/app2/tests/adir/test_module_d.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = \
            'from applications.app2.modules.adir.module_d import ClassD'
        self.assertEqual(test_file.import_line(), expect)
        return
예제 #4
0
    def test__module_file(self):
        filename = os.path.join(root_path(),
                                'applications/app1/tests/test_module_a.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = os.path.join(root_path(),
                              'applications/app1/modules/module_a.py')
        self.assertEqual(test_file.module_file(), expect)

        # Test parse with script with sub directory

        filename = os.path.join(root_path(),
                                'applications/app2/tests/adir/test_module_d.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        expect = os.path.join(root_path(),
                              'applications/app2/modules/adir/module_d.py'
                              )
        self.assertEqual(test_file.module_file(), expect)
        return
예제 #5
0
    def test__parse(self):
        filename = os.path.join(root_path(),
                                'applications/app1/tests/test_module_a.py'
                                )
        test_file = File(filename, root_path())

        # Test parse with script without sub directory

        test_file.parse()
        self.assertEqual(test_file.application, 'app1')
        self.assertEqual(test_file.sub_directory, '')
        self.assertEqual(test_file.module, 'module_a')

        # Test parse with script with sub directory

        filename = os.path.join(root_path(),
                                'applications/app2/tests/adir/test_module_d.py'
                                )
        test_file = File(filename, root_path())
        test_file.parse()
        self.assertEqual(test_file.application, 'app2')
        self.assertEqual(test_file.sub_directory, 'adir')
        self.assertEqual(test_file.module, 'module_d')
        return