当前位置: 首页>>代码示例>>Python>>正文


Python TempDirectory.check方法代码示例

本文整理汇总了Python中testfixtures.TempDirectory.check方法的典型用法代码示例。如果您正苦于以下问题:Python TempDirectory.check方法的具体用法?Python TempDirectory.check怎么用?Python TempDirectory.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testfixtures.TempDirectory的用法示例。

在下文中一共展示了TempDirectory.check方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_evaulate_write

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import check [as 别名]
 def test_evaulate_write(self):
     dir = TempDirectory()
     d = TestContainer('parsed',FileBlock('foo','content','write'))
     d.evaluate_with(Files('td'),globs={'td':dir})
     compare([C(FileResult,
                passed=True,
                expected=None,
                actual=None)],
             [r.evaluated for r in d])
     dir.check('foo')
     compare(dir.read('foo'),'content')
开发者ID:Lothiraldan,项目名称:testfixtures,代码行数:13,代码来源:test_manuel.py


示例2: HomeDirTest

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import check [as 别名]
class HomeDirTest(unittest.TestCase):

    def setUp(self):
        self.temp_dir = TempDirectory(create=True)
        self.home = PathHomeDir(self.temp_dir.path)

    def tearDown(self):
        self.temp_dir.cleanup()

    def test_read(self):
        self.temp_dir.write("filename", "contents")
        self.assertEquals(self.home.read("filename"), "contents")

    def test_write(self):
        self.temp_dir.write("existing_file", "existing_contents")
        self.home.write("new_file", "contents")
        self.home.write("existing_file", "new_contents")
        self.assertEquals(self.temp_dir.read("existing_file"),
                          "new_contents")
        self.assertEquals(self.temp_dir.read("new_file"), "contents")

    def test_config_file(self):
        with collect_outputs() as outputs:
            self.home.write_config_file("new config")
            self.temp_dir.check(".cosmosrc")
            self.assertEquals(self.home.read_config_file(), "new config")
            self.assertIn("Settings saved", outputs.stdout.getvalue())
            file_mode = os.stat(self.temp_dir.getpath(".cosmosrc")).st_mode
            self.assertEquals(file_mode, stat.S_IFREG | stat.S_IRUSR | stat.S_IWUSR)

    def test_override_config_file(self):
        with collect_outputs():
            other_config = self.temp_dir.write("path/other", "config")
            self.assertEquals(
                self.home.read_config_file(filename_override=other_config),
                "config")

    def test_warn_on_unprotected_config_file(self):
        with collect_outputs() as outputs:
            self.home.write_config_file("new config")
            config_path = self.temp_dir.getpath(".cosmosrc")
            os.chmod(config_path, 0777)
            self.home.read_config_file()
            assertFunc = (self.assertNotIn if os.name=='nt' else self.assertIn)
            assertFunc("WARNING", outputs.stderr.getvalue())

    def test_last_cluster(self):
        self.home.write_last_cluster("0000000")
        self.temp_dir.check(".cosmoslast")
        self.assertEquals(self.home.read_last_cluster(), "0000000")
开发者ID:adamosloizou,项目名称:fiware-cosmos-platform,代码行数:52,代码来源:test_home_dir.py


示例3: Test_directory_fill_helpers

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import check [as 别名]
class Test_directory_fill_helpers(TestCase):
    def setUp(self):
        self.testDir = TempDirectory()

    def tearDown(self):
        self.testDir.cleanup()

    def test_generate_filenames_one_file(self):
        fileNames = generate_filenames(1)
        self.assertTrue(fileNames == ['file0'])

    def test_generate_filenames_number_out_of_range(self):
        self.assertRaises(ValueError, generate_filenames, 0)
        self.assertRaises(ValueError, generate_filenames, 11)

    def test_generate_filenames_two_files(self):
        fileNames = generate_filenames(2)
        self.assertTrue(fileNames == ['file0', 'file1'])

    def test_genertate_file_contents_one_file(self):
        fileContents = generate_file_contents(1)
        self.assertTrue(fileContents == [''])

    def test_generate_file_contents_number_out_of_range(self):
        self.assertRaises(ValueError, generate_file_contents, 0)
        self.assertRaises(ValueError, generate_file_contents, 11)

    def test_generate_file_contents_two_files(self):
        fileContents = generate_file_contents(2)
        self.assertTrue(fileContents == ['', '1'])

    def test_write_test_files_one_file(self):
        fileNames = generate_filenames(1)
        fileContents = generate_file_contents(1)
        files = zip(fileNames, fileContents)
        write_files(self.testDir, files)
        self.testDir.check(*fileNames)

    def test_write_test_files_ten_files(self):
        fileNames = generate_filenames(10)
        fileContents = generate_file_contents(10)
        files = zip(fileNames, fileContents)
        write_files(self.testDir, files)
        self.testDir.check(*fileNames)

    def test_create_files_one_file(self):
        create_files(self.testDir, 1)
        self.testDir.check(*generate_filenames(1))

    def test_create_files_ten_files(self):
        create_files(self.testDir, 10)
        self.testDir.check(*generate_filenames(10))

    def test_generate_dirnames_one_dir(self):
        dirNames = generate_dirnames(1)
        self.assertTrue(dirNames == ['dir0'])

    def test_generate_dirnames_two_dirs(self):
        dirNames = generate_dirnames(2)
        self.assertTrue(dirNames == ['dir0', 'dir1'])

    def test_generate_dirnames_number_out_of_range(self):
        self.assertRaises(ValueError, generate_dirnames, 0)
        self.assertRaises(ValueError, generate_dirnames, 11)

    def test_create_directories_one_dir(self):
        create_directories(self.testDir, 1)
        self.testDir.check(*generate_dirnames(1))

    def test_create_directories_ten_dirs(self):
        create_directories(self.testDir, 10)
        self.testDir.check(*generate_dirnames(10))
开发者ID:nbarendt,项目名称:PgsqlBackup,代码行数:74,代码来源:test_directory_fill_helpers.py


示例4: TestTestcase

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import check [as 别名]
class TestTestcase():
    """ Test the testcase class """

    def __init__(self):
        self.tempdir = TempDirectory()
        self.work_dir = self.tempdir.path

    def setUp(self):

        self.dt = {'type': 'string',
                'include':
                '#include <stdio.h>\n#include "foo.h"\n#include <stdlib.h>',
                'define': '', 'init': '', 'activation': ''
                }

        self.testcase_id = 42
        self.function_name = 'test_function_name'

        self.c_types = [1, 2]

        setting = Setting(42, 'setting', 0, self.dt, 'code',
                21, self.work_dir)
        self.settings = [setting]
        self.ret_val = 'ret_type'
        self.fun_header = '#include <stdio.h>\n'

    def tearDown(self):
        self.tempdir.cleanup()

    def test_get_id(self):
        """ get_id should return the supplied id """
        TEST_ID = 21
        tc = Testcase(TEST_ID, self.function_name,
                self.settings, self.work_dir, self.c_types, self.ret_val,
                self.fun_header)
        assert_equal(tc.get_id(), TEST_ID, 'ID is not matching')

    def test_get_setting(self):
        """ get_setting should return supplied setting """
        TEST_SETTING = self.settings
        tc = Testcase(self.testcase_id, self.function_name,
                TEST_SETTING, self.work_dir, self.c_types, self.ret_val,
                self.fun_header)
        assert_equal(tc.get_settings(), TEST_SETTING,
                'Setting is not matching')

    def test_get_name(self):
        """ get_name should return supplied name """
        TEST_NAME = 'TC_bar_42'
        tc = Testcase(self.testcase_id, 'bar', self.settings,
                self.work_dir, self.c_types, self.ret_val, self.fun_header)
        assert_equal(tc.get_name(), TEST_NAME,
        'Name is not matching: {0} != {1}'.format(tc.get_name(), TEST_NAME))

    def test_generate_files(self):
        """ generate_files should create the header file for
        this testcase """
        tc = Testcase(self.testcase_id, self.function_name,
                self.settings, self.work_dir, self.c_types, self.ret_val,
                self.fun_header)
        tc.generate_files()
        self.tempdir.check('TC_test_function_name_42.cpp',
                'TC_test_function_name_42.h')
开发者ID:DEEDS-TUD,项目名称:Slingshot,代码行数:65,代码来源:testcase_test.py


示例5: TestSetting

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import check [as 别名]
class TestSetting():
    """ Test the setting class """

    def setUp(self):
        """ Setup test fixtures """

        self.setting_id = 42
        self.setting_name = 'test_setting_name'
        self.setting_position = 0
        self.dt = {'type': 'string',
                'include':
                '#include <stdio.h>\n#include "foo.h"\n#include <stdlib.h>',
                'define': '', 'init': '', 'activation': ''}
        self.setting_code = 'code'
        self.function_ref = 1
        self.tempdir = TempDirectory()
        self.work_dir = self.tempdir.path

    def tearDown(self):
        """ Remove artefacts """
        self.tempdir.cleanup()

    def test_get_name(self):
        """get_name should return the supplied name"""
        TEST_NAME = 'test_name'
        setting = Setting(self.setting_id, TEST_NAME, self.setting_position,
                self.dt, self.setting_code, self.function_ref, self.work_dir)

        assert_equal(setting.get_name(), TEST_NAME)

    def test_get_id(self):
        """get_id should return the supplied id"""
        TEST_ID = 43
        setting = Setting(TEST_ID, self.setting_name, self.setting_position,
                self.dt, self.setting_code, self.function_ref, self.work_dir)

        assert_equal(setting.get_id(), TEST_ID)

    def test_get_position(self):
        """get_position should return the supplied position"""
        TEST_POSITION = 1
        setting = Setting(self.setting_id, self.setting_name, TEST_POSITION,
                self.dt, self.setting_code, self.function_ref, self.work_dir)

        assert_equal(setting.get_position(), TEST_POSITION)

    def test_get_code(self):
        """get_code should return the supplied code"""
        TEST_CODE = 'if (foo) { bar; }'
        setting = Setting(self.setting_id, self.setting_name,
                self.setting_position, self.dt, TEST_CODE, self.function_ref,
                self.work_dir)

        assert_equal(setting.get_code(), TEST_CODE)

    def test_get_function_ref(self):
        """get_function_ref should return the supplied function_ref"""
        TEST_F_REF = 22
        setting = Setting(self.setting_id, self.setting_name,
                self.setting_position, self.dt, self.setting_code, TEST_F_REF,
                self.work_dir)

        assert_equal(setting.get_function_ref(), TEST_F_REF)

    def test_get_datatype(self):
        """get_datatype should return the supplied datatype record"""
        TEST_DT = self.dt
        setting = Setting(self.setting_id, self.setting_name,
                self.setting_position, TEST_DT, self.setting_code,
                self.function_ref, self.work_dir)

        assert_equal(setting.get_datatype(), TEST_DT)

    def test_ballista_settings_get_removed(self):
        """all ballista includes should be removed from the datatype include
        string """
        setting = Setting(self.setting_id, self.setting_name,
                self.setting_position, self.dt, self.setting_code,
                self.function_ref, self.work_dir)

        assert_equal(setting.get_datatype()['include'],
                '#include <stdio.h>\n\n#include <stdlib.h>')

    def test_generate_files(self):
        """ generating the setting files should create header and cpp files """
        setting = Setting(self.setting_id, 't_name_42',
                self.setting_position, self.dt, self.setting_code,
                self.function_ref, self.work_dir)
        setting.generate_files()
        self.tempdir.check('t_name_42.cpp', 't_name_42.h')
开发者ID:DEEDS-TUD,项目名称:Slingshot,代码行数:92,代码来源:setting_test.py



注:本文中的testfixtures.TempDirectory.check方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。