Example #1
0
 def setUp(self):
     self._name = "foo"
     self._invocation = Invocation()
Example #2
0
class InvocationTests(TestCase):

    def setUp(self):
        self._name = "foo"
        self._invocation = Invocation()

    def test_name_definition(self):
        self._invocation.name = self._name
        self.assertEqual(self._name, self._invocation.name)

    def test_defining_named_arguments(self):
        self._invocation.append_argument("bar", ["a", "b", "c"])
        self.assertEqual(["a", "b", "c"], self._invocation.argument("bar"))

    def test_as_text(self):
        self._invocation.name = [r"\foo"]
        self._invocation.append_argument("options", [each for each in "[this is a text]"])
        self._invocation.append(["-", "---"])
        self._invocation.append_argument("link", [each for each in "{link/to/a/file.tex}"])
        self.assertEqual(r"\foo[this is a text]----{link/to/a/file.tex}", self._invocation.as_text)

    def test_conversion_to_token_list(self):
        self._invocation.name = [r"\foo"]
        self._invocation.append_argument("options", [each for each in "[this is a text]"])
        self._invocation.append("----")
        self._invocation.append_argument("link", [each for each in "{link/to/a/file.tex}"])
        self.assertEqual([r"\foo"] + \
                         [each for each in "[this is a text]"] + \
                         [each for each in "----"] + \
                         [each for each in "{link/to/a/file.tex}"],
                         self._invocation.as_tokens)

    def test_iterating_over_items(self):
        self._invocation.name = r"\foo"
        self._invocation.append_argument("options", "this is a text")
        self._invocation.append("----")
        self._invocation.append_argument("link", "{link/to/a/file.tex}")
        self.assertEqual({"options": "this is a text",
                          "link": "{link/to/a/file.tex}"},
                         self._invocation.arguments)

    def test_argument_substitution(self):
        self._invocation.name = r"\foo"
        self._invocation.append_argument("text", ["z", "y", "x"])
        self.assertEqual("bar", self._invocation.substitute("text", "bar").arguments["text"])

    def test_argument(self):
        self._invocation.name = [r"\foo"]
        self._invocation.append_argument("link", ["p1", ",", "p2"])
        self.assertEquals([r"\foo"], self._invocation.name)