示例#1
0
    def test_locate_file(self):
        with pytest.raises(exceptions.FileNotFoundError):
            loader.locate_file(os.getcwd(), 'custom_functions.py')

        with pytest.raises(exceptions.FileNotFoundError):
            loader.locate_file('', 'custom_functions.py')

        start_path = os.path.join(os.getcwd(), 'tests')
        assert loader.locate_file(start_path,
                                  'custom_functions.py') == os.path.join(
                                      'tests', 'custom_functions.py')

        assert loader.locate_file('tests/',
                                  'custom_functions.py') == os.path.join(
                                      'tests', 'custom_functions.py')

        assert loader.locate_file('tests',
                                  'custom_functions.py') == os.path.join(
                                      'tests', 'custom_functions.py')

        assert loader.locate_file('tests/base.py',
                                  'custom_functions.py') == os.path.join(
                                      'tests', 'custom_functions.py')

        assert loader.locate_file('tests/testcase/smoke_test.yml',
                                  'custom_functions.py') == os.path.join(
                                      'tests', 'custom_functions.py')
示例#2
0
    def test_locate_file(self):
        with self.assertRaises(exceptions.FileNotFound):
            loader.locate_file(os.getcwd(), "debugtalk.py")

        with self.assertRaises(exceptions.FileNotFound):
            loader.locate_file("", "debugtalk.py")

        start_path = os.path.join(os.getcwd(), "tests")
        self.assertEqual(
            loader.locate_file(start_path, "debugtalk.py"),
            os.path.join(
                os.getcwd(), "tests/debugtalk.py"
            )
        )
        self.assertEqual(
            loader.locate_file("tests/", "debugtalk.py"),
            os.path.join(os.getcwd(), "tests", "debugtalk.py")
        )
        self.assertEqual(
            loader.locate_file("tests", "debugtalk.py"),
            os.path.join(os.getcwd(), "tests", "debugtalk.py")
        )
        self.assertEqual(
            loader.locate_file("tests/base.py", "debugtalk.py"),
            os.path.join(os.getcwd(), "tests", "debugtalk.py")
        )
        self.assertEqual(
            loader.locate_file("tests/data/demo_testcase.yml", "debugtalk.py"),
            os.path.join(os.getcwd(), "tests", "debugtalk.py")
        )
示例#3
0
    def test_locate_file(self):
        with pytest.raises(exceptions.FileNotFound):
            loader.locate_file(os.getcwd(), 'confcustom.py')

        with pytest.raises(exceptions.FileNotFound):
            loader.locate_file('', 'confcustom.py')

        start_path = os.path.join(os.getcwd(), 'tests')
        assert loader.locate_file(start_path, 'confcustom.py') == os.path.join(
            os.getcwd(), 'tests', 'confcustom.py')

        assert loader.locate_file('tests/', 'confcustom.py') == os.path.join(
            'tests', 'confcustom.py')
        assert loader.locate_file('tests', 'confcustom.py') == os.path.join(
            'tests', 'confcustom.py')
        assert loader.locate_file('tests/base.py',
                                  'confcustom.py') == os.path.join(
                                      'tests', 'confcustom.py')
        assert loader.locate_file('tests/data/account.csv',
                                  'confcustom.py') == os.path.join(
                                      'tests', 'confcustom.py')
示例#4
0
    def load_csv_list(self, csv_file_name, fetch_method="Sequential"):
        """ locate csv file and load csv content.

        Args:
            csv_file_name (str): csv file name
            fetch_method (str): fetch data method, defaults to Sequential.
                If set to "random", csv data list will be reordered in random.

        Returns:
            list: csv data list
        """
        csv_file_path = loader.locate_file(self.file_path, csv_file_name)
        csv_content_list = loader.load_file(csv_file_path)

        if fetch_method.lower() == "random":
            random.shuffle(csv_content_list)

        return csv_content_list
示例#5
0
    def test_locate_file(self):
        with self.assertRaises(exceptions.FileNotFound):
            loader.locate_file(os.getcwd(), "debugtalk.py")

        with self.assertRaises(exceptions.FileNotFound):
            loader.locate_file("", "debugtalk.py")

        start_path = os.path.join(os.getcwd(), "examples", "httpbin")
        self.assertEqual(
            loader.locate_file(start_path, "debugtalk.py"),
            os.path.join(os.getcwd(), "examples", "httpbin", "debugtalk.py"),
        )
        self.assertEqual(
            loader.locate_file("examples/httpbin/", "debugtalk.py"),
            os.path.join(os.getcwd(), "examples", "httpbin", "debugtalk.py"),
        )
        self.assertEqual(
            loader.locate_file("examples/httpbin/", "debugtalk.py"),
            os.path.join(os.getcwd(), "examples", "httpbin", "debugtalk.py"),
        )