1 | # |
||
2 | # Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com> |
||
3 | # License: MIT |
||
4 | # |
||
5 | # pylint: disable=missing-docstring |
||
6 | import os.path |
||
7 | import subprocess |
||
8 | import unittest |
||
9 | |||
10 | import tests.common |
||
11 | |||
12 | |||
13 | SCRIPT_TO_USE_ANYCONFIG = """\ |
||
14 | #! /usr/bin/env python |
||
15 | import anyconfig |
||
16 | |||
17 | c = anyconfig.load("/") or {} |
||
18 | anyconfig.dump(c, "/dev/null", "yaml") |
||
19 | """ |
||
20 | |||
21 | |||
22 | def check_output(cmd): |
||
23 | devnull = open('/dev/null', 'w') |
||
24 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=devnull) |
||
25 | return proc.communicate()[0] |
||
26 | |||
27 | |||
28 | View Code Duplication | class Test(unittest.TestCase): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
29 | |||
30 | def setUp(self): |
||
31 | self.workdir = tests.common.setup_workdir() |
||
32 | self.script = os.path.join(self.workdir, "a.py") |
||
33 | |||
34 | def tearDown(self): |
||
35 | tests.common.cleanup_workdir(self.workdir) |
||
36 | |||
37 | def test_00_run_script(self): |
||
38 | with open(self.script, 'w') as fileobj: |
||
39 | fileobj.write(SCRIPT_TO_USE_ANYCONFIG) |
||
40 | |||
41 | out = check_output(["python", self.script]) |
||
42 | self.assertTrue(out in (b'', '')) |
||
43 | |||
44 | # vim:sw=4:ts=4:et: |
||
45 |