Exemplo n.º 1
0
    def test_env(self):
        env = {'V1': 'V1SET'}
        result = m.run(['/bin/sh', '-c', 'echo $V1'], env=env)
        self.assertIn(b'V1SET', result.stdout)

        os.environ['V2'] = 'V2SET'
        result = m.run(['/bin/sh', '-c', 'echo $V2'], env=env)
        self.assertNotIn(b'V2SET', result.stdout)
Exemplo n.º 2
0
    def test_option_keep_database_database_remains_available(self):
        f = fixtures.PluginContext(
            """\
            Postgres:
                keep database: True
            """
        )

        try:
            with f.plugin:
                self.check_psql_default_database(f.plugin.database)

            self.check_database_exists(f.plugin.database)
        finally:
            external_process.run(["dropdb", f.plugin.database])
Exemplo n.º 3
0
    def check_database_exists(self, database):
        result = external_process.run(["psql", "-c", r"\list"])

        raw_database = database.encode("utf8")
        self.assertEqual(0, result.status)
        self.assertIn(raw_database, result.stdout)
        self.assertNotIn(raw_database, result.stderr)
Exemplo n.º 4
0
    def check_psql_default_database(self, database):
        result = external_process.run(["psql", "-c", r"\conninfo"])

        raw_database = database.encode("utf8")
        self.assertEqual(0, result.status)
        self.assertIn(raw_database, result.stdout)
        self.assertNotIn(raw_database, result.stderr)
Exemplo n.º 5
0
    def test_module_in_virtualenv_is_available(self):
        f = fixtures.PluginContext(
            """\
            PythonDependencies:
                - roman==2.0.0
            """
        )

        # verify, that we can import the required "roman" module
        cmdspec = ["python", "-c", "import roman; print(roman.toRoman(23))"]

        with f.plugin:
            result = external_process.run(cmdspec)

        # if result.status: print(result)
        self.assertEqual(b"XXIII", result.stdout.rstrip())
Exemplo n.º 6
0
    def test_new_virtualenv_has_all_the_required_packages(self):
        f = fixtures.PluginContext(
            """\
            PythonDependencies:
                - roman==2.0.0
            """
        )
        with f.plugin:
            python = f.plugin.virtualenv_dir / "bin/python"

        # verify, that we can import the required "roman" module
        program = "import roman; print(roman.toRoman(23))"
        cmdspec = [python.path, "-c", program]
        result = external_process.run(cmdspec)

        # if result.status: print(result)
        self.assertEqual(b"XXIII", result.stdout.rstrip())
Exemplo n.º 7
0
 def test_str(self):
     result = m.run(
         ['/bin/sh', '-c', 'echo test output; echo test stderr >&2']
         )
     expected = textwrap.dedent(
         u'''\
         Command execution result
         COMMAND:
           ('/bin/sh', '-c', 'echo test output; echo test stderr >&2')
         STATUS:
           0
         STDOUT:
           test output
         STDERR:
           test stderr
         ''').splitlines()
     actual = str(result).splitlines()
     self.assertListEqual(expected, actual)
Exemplo n.º 8
0
 def test_stdout(self):
     result = m.run(['/bin/sh', '-c', 'echo test output'])
     self.assertEqual(b'test output', result.stdout.rstrip())
Exemplo n.º 9
0
 def test_cwd(self):
     wd = os.getcwdu().encode('utf8')
     with in_temp_dir():
         result = m.run(['/bin/sh', '-c', 'pwd'], cwd=wd)
     self.assertEqual(wd, result.stdout.rstrip())
Exemplo n.º 10
0
 def test_status(self):
     result = m.run(['/bin/sh', '-c', 'exit 31'])
     self.assertEqual(31, result.status)