本文整理汇总了Python中scripttest.TestFileEnvironment.writefile方法的典型用法代码示例。如果您正苦于以下问题:Python TestFileEnvironment.writefile方法的具体用法?Python TestFileEnvironment.writefile怎么用?Python TestFileEnvironment.writefile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scripttest.TestFileEnvironment
的用法示例。
在下文中一共展示了TestFileEnvironment.writefile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIntegration
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
class TestIntegration(unittest.TestCase):
def setUp(self):
self.env = TestFileEnvironment(test_path, template_path=template_path)
def test_init(self):
result = self.env.run("gpc", "init", expect_stderr=True)
created_filenames = result.files_created.keys()
self.assertTrue("log" in created_filenames)
self.assertTrue("log/data" in created_filenames)
self.assertTrue("log/schema.sql" in created_filenames)
self.assertTrue("storage" in created_filenames)
def test_make_target(self):
self.env.run("gpc", "init", expect_stderr=True)
self.env.writefile("gpc.yaml", frompath="simple.yaml")
result = self.env.run("gpc", "make", "c", expect_stderr=True)
created_filenames = list(result.files_created.keys())
self.assertTrue("c" in created_filenames)
created_filenames.remove("c")
self.assertTrue(any([s.startswith("storage/") for s in created_filenames]))
self.assertTrue(any([s.startswith("log/data/") for s in created_filenames]))
def test_make_target_cached(self):
call(["cp", "-r", template_path + "/.gpc", test_path])
call(["cp", "-r", template_path + "/log", test_path])
call(["cp", "-r", template_path + "/storage", test_path])
self.env.writefile("gpc.yaml", frompath="simple.yaml")
result = self.env.run("gpc", "make", "c", expect_stderr=True)
created_filenames = result.files_created.keys()
self.assertTrue("c" in created_filenames)
self.assertTrue(len(created_filenames) == 1)
示例2: test_dojorun_dryrun
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
def test_dojorun_dryrun(self):
"""Testing dojorun.py script in dry-run mode."""
env = self.get_env()
# Build new env to run the script in dry-run mode
# Copy file from data to env.
env = TestFileEnvironment(template_path=pdj_data.dirpath)
env.writefile("Si.psp8", frompath="Si.psp8")
env.writefile("Si.djrepo", frompath="Si.djrepo_empty")
env.run(self.script, "Si.psp8", self.loglevel, self.verbose, "--dry-run")
示例3: get_env
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
def get_env(self):
#import tempfile
#env = TestFileEnvironment(tempfile.mkdtemp(suffix='', prefix='test_' + script))
env = TestFileEnvironment()
# Use Agg backend for plots.
env.writefile("matplotlibrc", "backend : Agg")
# Start with --help. If this does not work...
env.run(self.script, "--help")
# Script must provide a version option
r = env.run(self.script, "--version", expect_stderr=True)
assert r.stderr.strip() == "%s version %s" % (os.path.basename(self.script), abilab.__version__)
return env
示例4: EnvironmentUnderTest
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
class EnvironmentUnderTest(object):
def __init__(self):
self.reset()
def reset(self):
environ = os.environ.copy()
environ.update({'PATH': os.path.join(TEST_OUTPUT_DIR, 'bin',
os.pathsep, environ['PATH'])})
self._env = TestFileEnvironment(environ=environ)
self._env.run(sys.executable, '-m', 'virtualenv',
'--no-site-packages',
self._env.base_path)
self._env.run('python setup.py install', cwd=package_dir)
def run(self, *args, **kw):
return self._env.run(*args, **kw)
def mkdir(self, path):
return os.mkdir(os.path.join(self._env.base_path, path))
def writefile(self, *args, **kw):
return self._env.writefile(*args, **kw)
示例5: EnvbTest
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
class EnvbTest(object):
env_file = ''
def setUp(self):
self.env = TestFileEnvironment('tmp')
assert self.env_file
self.env.writefile('.env', content=self.env_file)
示例6: TestPyfdaCommandLineTool
# 需要导入模块: from scripttest import TestFileEnvironment [as 别名]
# 或者: from scripttest.TestFileEnvironment import writefile [as 别名]
class TestPyfdaCommandLineTool(TestCase):
def setUp(self):
self.env = TestFileEnvironment(
base_path=TEST_DIR,
template_path=TEMPLATE_DIR,
cwd=os.getcwd(),
ignore_hidden=False)
self.env.writefile(INPUT_FILE_NAME,
frompath='test_freq_2_then_1_then_8_then_4.fda')
def test_no_arguments(self):
'Test: pyfda.py'
cmd = './pyfda.py'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 2,\
'Expect returncode=2, got %r' % result.returncode)
self.assertEqual(result.stderr[:7], 'usage: ', \
'Incorrect usage message')
message = 'error: too few arguments\n'
self.assertEqual(result.stderr[-len(message):], message, \
'Incorrect error message')
def test_setup_missing_frequency_argument(self):
'Test: pyfda setup'
cmd = './pyfda.py setup'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: Missing --frequency argument with command: setup\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_info_missing_fda_file(self):
'Test: pyfda info'
cmd = './pyfda.py info'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: Missing fda_file argument with command: info\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_convert_missing_fda_file(self):
'Test: pyfda convert'
cmd = './pyfda.py convert'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: Missing fda_file argument with command: convert\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_convert_too_much_temperature_arguments(self):
'Test: pyfda convert file.fda --celsius --fahrenheit'
cmd = './pyfda.py convert file.fda --celsius --fahrenheit'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: --celsius and --fahrenheit can not ' \
'be both specified.\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_convert_too_much_length_arguments(self):
'Test: pyfda convert file.fda --feet --meters'
cmd = './pyfda.py convert file.fda --feet --meters'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: --meters and --feet can not be both specified.\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_convert_incorrect_last_negative_value(self):
'Test: pyfda convert file.fda --last -1'
cmd = './pyfda.py convert file.fda --last -1'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 1,\
'Expect returncode=1, got %r' % result.returncode)
expected = 'error: --last argument must be positive.\n'
self.assertEqual(result.stderr, expected, 'Incorrect error message')
def test_convert_incorrect_last_non_integer_value(self):
'Test: pyfda convert file.fda --last toto'
cmd = './pyfda.py convert file.fda --last toto'
result = self.env.run(cmd, expect_error=True)
self.assertEqual(result.returncode, 2,\
#.........这里部分代码省略.........