Пример #1
0
 def test_redirection(self):
     obj = CommandStrategy("exit > path/to/file.txt")
     assert obj.command_tokens == ["exit"]
     obj = CommandStrategy('exist intent "test" >> file/no/extension')
     assert obj.command_tokens == ["exist", "intent", '"test"']
     obj = CommandStrategy("test something /else/i  > ")
     assert obj.command_tokens == ["test", "something", "/else/i"]
Пример #2
0
 def test_regex(self):
     assert CommandStrategy("").get_regex_name("/regex/") == \
            re.compile("regex")
     assert CommandStrategy("").get_regex_name("/test.*/") == \
            re.compile("test.*")
     assert CommandStrategy("").get_regex_name("/some[0-9]/i") == \
            re.compile("some[0-9]", re.IGNORECASE)
     obj = CommandStrategy("")
     assert obj.get_regex_name("/test/g") == re.compile("test")
     assert obj._is_regex_global
     obj = CommandStrategy("")
     assert obj.get_regex_name("/$x+^/ig") == re.compile(
         "$x+^", re.IGNORECASE)
     assert obj._is_regex_global
Пример #3
0
 def test(self):
     CommandStrategy("").finish_execution()
Пример #4
0
 def test_should_be_overriden(self):
     with pytest.raises(NotImplementedError):
         CommandStrategy("").execute_on_unit(None, None, None)
Пример #5
0
 def test(self):
     with pytest.raises(NotImplementedError):
         CommandStrategy("NOTHING alias a, b, c").execute()
Пример #6
0
 def test(self):
     assert not CommandStrategy("").should_exit()
Пример #7
0
 def test_flush(self):
     CommandStrategy("").flush_output()
Пример #8
0
 def test_no_regex(self):
     assert CommandStrategy("").get_regex_name("exit") is None
     assert CommandStrategy("").get_regex_name('"alias"') is None
     assert CommandStrategy("").get_regex_name('"something with/slash"') \
            is None
Пример #9
0
 def test_empty_command(self):
     assert CommandStrategy("").get_regex_name("") is None