Exemplo n.º 1
0
 def test_call(self, capfd, node_package_command, node_package_command_args,
               node_package_command_output_regex):
     command = Command(node_package_command)
     assert command.call(node_package_command_args) is 0
     out, err = capfd.readouterr()
     assert node_package_command_output_regex.match(out.strip())
     assert not err
Exemplo n.º 2
0
    def test_Popen_non_zero_returncode(self, node_package_command):
        command = Command(node_package_command)
        process = command.Popen('--non-existent',
                                stdout=PIPE,
                                stderr=PIPE,
                                universal_newlines=True)

        out, err = process.communicate()
        assert process.returncode is not 0
        assert not out and err
Exemplo n.º 3
0
    def test_check_output(self, capfd, node_package_command,
                          node_package_command_args,
                          node_package_command_output_regex):
        command = Command(node_package_command)
        assert node_package_command_output_regex.match(
            command.check_output(node_package_command_args,
                                 universal_newlines=True))

        out, err = capfd.readouterr()
        assert not out and not err
Exemplo n.º 4
0
    def test_call_non_zero_returncode(
        self,
        capfd,
        node_package_command,
    ):
        command = Command(node_package_command)
        assert command.call(['--non-existent']) is not 0

        out, err = capfd.readouterr()
        assert not out and err
Exemplo n.º 5
0
 def test_Popen(self, node_package_command, node_package_command_args,
                node_package_command_output_regex):
     command = Command(node_package_command)
     process = command.Popen(node_package_command_args,
                             stdout=PIPE,
                             stderr=PIPE,
                             universal_newlines=True)
     out, err = process.communicate()
     assert node_package_command_output_regex.match(out.strip())
     assert not err
Exemplo n.º 6
0
    def test_check_output_raises(self, capfd, node_package_command):
        command = Command(node_package_command)
        with pytest.raises(NodeCommandError,
                           match=(r"^Command '\[[^,]+, '--non-existent'\]' "
                                  r"returned non-zero exit status -?\d+ "
                                  r"in working directory {}$".format(
                                      re.escape(repr(os.getcwd()))))):

            command.check_output(['--non-existent'], stderr=STDOUT)

        out, err = capfd.readouterr()
        assert not out and not err
Exemplo n.º 7
0
 def test_name(self, node_package_command):
     assert Command.name is not Path.name
     assert Command(node_package_command).name == node_package_command
Exemplo n.º 8
0
 def test__new__non_existent(self):
     with pytest.raises((IOError, OSError)):
         Command('non_existent')
Exemplo n.º 9
0
 def test__new__(self, node_package_command):
     command = Command(node_package_command)
     assert Path(command).normcase() \
         == nodely.which(node_package_command).normcase()
Exemplo n.º 10
0
 def test__repr__(self, node_package_command):
     assert (repr(Command(node_package_command)) ==
             "nodely.bin['{}']".format(node_package_command))
Exemplo n.º 11
0
 def test__repr__(self, node_package_command):
     assert repr(Command(node_package_command)) \
         == "nodely.bin[{!r}]".format(node_package_command)