示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#8
0
 def test__new__non_existent(self):
     with pytest.raises((IOError, OSError)):
         Command('non_existent')
示例#9
0
 def test__new__(self, node_package_command):
     command = Command(node_package_command)
     assert Path(command).normcase() \
         == nodely.which(node_package_command).normcase()
示例#10
0
 def test__repr__(self, node_package_command):
     assert (repr(Command(node_package_command)) ==
             "nodely.bin['{}']".format(node_package_command))
示例#11
0
 def test__repr__(self, node_package_command):
     assert repr(Command(node_package_command)) \
         == "nodely.bin[{!r}]".format(node_package_command)