Пример #1
0
 def command_callable(command, stdin):
     if 'cloc' in command:
         return PopenBehaviour(stdout=cloc_out)
     elif 'xcodebuild -version' in command:
         return PopenBehaviour(
             stdout=b'Xcode 10.0\nBuild version 10A255\n')
     return PopenBehaviour(stdout=b'test_out', stderr=b'test_error')
Пример #2
0
 def commands_mock(command, stdin):
     # if we want to have e.g. some commands fail,
     # we can have overrides happen here.
     # unfortunately, cutting out SSH prefixes and such
     # is, to put it lightly, non-trivial
     if "uptime" in command:
         return PopenBehaviour(stdout=b"MOCKED uptime")
     if "rsync" in command:
         return PopenBehaviour(stdout=b"MOCKED rsync")
     if "ray" in command:
         return PopenBehaviour(stdout=b"MOCKED ray")
     return PopenBehaviour(stdout=b"MOCKED GENERIC")
Пример #3
0
    def test_multiple_responses(self):
        # set up
        behaviours = [
            PopenBehaviour(stderr=b'e', returncode=1),
            PopenBehaviour(stdout=b'o'),
        ]

        def behaviour(command, stdin):
            return behaviours.pop(0)

        self.Popen.set_command('svn ls -R foo', behaviour=behaviour)

        # testing of error:
        with ShouldRaise(RuntimeError('something bad happened')):
            my_func()
        # testing of second call:
        compare(my_func(), b'o')
Пример #4
0
 def commands_mock(command, stdin):
     # TODO(maximsmol): this is a hack since stdout=sys.stdout
     #                  doesn't work with the mock for some reason
     if "rsync" not in command:
         print("This is a test!")
     return PopenBehaviour(stdout=b"This is a test!")
Пример #5
0
 def commands_mock(command, stdin):
     # TODO(maximsmol): this is a hack since stdout=sys.stdout
     #                  doesn't work with the mock for some reason
     print("ubuntu@ip-.+:~$ exit")
     return PopenBehaviour(stdout="ubuntu@ip-.+:~$ exit")
Пример #6
0
 def some_callable(command, stdin):
     return PopenBehaviour(BytesLiteral(command), BytesLiteral(stdin),
                           1, 345, 0)
Пример #7
0
 def commands_mock(command, stdin):
     print("This is a test!")
     return PopenBehaviour(stdout=b"This is a test!")
Пример #8
0
 def __call__(self, command, stdin):
     while self.fail_count > 0:
         self.fail_count -= 1
         return PopenBehaviour(stderr=b'e', returncode=1)
     return PopenBehaviour(stdout=b'o')
Пример #9
0
 def command_callable(command, stdin):
     return PopenBehaviour(stdout=b'stdout')