예제 #1
0
    def testCapture(self):
        stdoutValue = "stdout"
        stderrValue = "stderr"

        def func():
            print(stdoutValue, file=sys.stdout, end="")
            print(stderrValue, file=sys.stderr, end="")

        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, stdoutValue)
        self.assertEqual(stderr, stderrValue)

        # Empty stdout
        def func():
            print(stderrValue, file=sys.stderr, end="")

        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, "")
        self.assertEqual(stderr, stderrValue)

        # Empty stderr
        def func():
            print(stdoutValue, file=sys.stdout, end="")

        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, stdoutValue)
        self.assertEqual(stderr, "")
예제 #2
0
 def captureCliOutput(self, command, arguments, outputFormat):
     clientCommand = "{} {} {} -O {}".format(
         command, self._dataUrl, arguments, outputFormat)
     stdout, stderr = utils.captureOutput(
         cli.client_main, clientCommand.split())
     self.assertEqual(len(stderr), 0)
     return stdout
예제 #3
0
 def captureCliOutput(self, command, arguments, outputFormat):
     clientCommand = "{} {} {} -O {}".format(command, self._dataUrl,
                                             arguments, outputFormat)
     stdout, stderr = utils.captureOutput(cli.client_main,
                                          clientCommand.split())
     self.assertEqual(len(stderr), 0)
     return stdout
예제 #4
0
파일: test_utils.py 프로젝트: Arc39/server
 def testArgs(self):
     def func(one, two, three, keywordOne=None, keywordTwo=None):
         print(one, two, three, keywordOne, keywordTwo, file=sys.stdout)
     stdout, stderr = utils.captureOutput(
         func, "1", "2", "3", keywordTwo="5", keywordOne="4")
     self.assertEqual(stdout, "1 2 3 4 5\n")
     self.assertEqual(stderr, "")
예제 #5
0
    def testArgs(self):
        def func(one, two, three, keywordOne=None, keywordTwo=None):
            print(one, two, three, keywordOne, keywordTwo, file=sys.stdout)

        stdout, stderr = utils.captureOutput(func,
                                             "1",
                                             "2",
                                             "3",
                                             keywordTwo="5",
                                             keywordOne="4")
        self.assertEqual(stdout, "1 2 3 4 5\n")
        self.assertEqual(stderr, "")
예제 #6
0
 def captureJsonOutput(self, command, arguments=""):
     """
     Runs the specified command add the JSON output option and
     returns the result as a list of JSON parsed dictionaries.
     """
     clientCommand = "{} {} {} -O json".format(
         command, self._dataUrl, arguments)
     stdout, stderr = utils.captureOutput(
         cli.client_main, clientCommand.split())
     cliOutput = []
     self.assertEqual(len(stderr), 0)
     for line in stdout.splitlines():
         cliOutput.append(json.loads(line))
     return cliOutput
예제 #7
0
 def captureJsonOutput(self, command, arguments=""):
     """
     Runs the specified command add the JSON output option and
     returns the result as a list of JSON parsed dictionaries.
     """
     clientCommand = "{} {} {} -O json".format(command, self._dataUrl,
                                               arguments)
     stdout, stderr = utils.captureOutput(cli.client_main,
                                          clientCommand.split())
     cliOutput = []
     self.assertEqual(len(stderr), 0)
     for line in stdout.splitlines():
         cliOutput.append(json.loads(line))
     return cliOutput
예제 #8
0
파일: test_utils.py 프로젝트: Arc39/server
    def testCapture(self):
        stdoutValue = "stdout"
        stderrValue = "stderr"

        def func():
            print(stdoutValue, file=sys.stdout, end="")
            print(stderrValue, file=sys.stderr, end="")
        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, stdoutValue)
        self.assertEqual(stderr, stderrValue)

        # Empty stdout
        def func():
            print(stderrValue, file=sys.stderr, end="")
        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, "")
        self.assertEqual(stderr, stderrValue)

        # Empty stderr
        def func():
            print(stdoutValue, file=sys.stdout, end="")
        stdout, stderr = utils.captureOutput(func)
        self.assertEqual(stdout, stdoutValue)
        self.assertEqual(stderr, "")