예제 #1
0
 def test_select(self):
     self.assertEqual(
         tokenise(
             "select customer, street1, \"limit\", 'addr''s' FROM Table").
         value, [("keyword", "select"), ("word", "customer"),
                 ("operator", ","), ("word", "street1"), ("operator", ","),
                 ("word", "limit"), ("operator", ","), ("word", "addr's"),
                 ("keyword", "from"), ("word", "Table")])
예제 #2
0
 def test_list_of_quotes(self):
     self.assertEqual(
         tokenise("\"foo\",\"bar\"").value, [("word", "foo"),
                                             ("operator", ","),
                                             ("word", "bar")])
예제 #3
0
 def test_sum(self):
     self.assertEqual([("number", "2"), ("operator", "+"), ("number", "2")],
                      tokenise("2+2").value)
예제 #4
0
 def test_quoted_word(self):
     self.assertEqual([("word", "hello")], tokenise("\"hello\"").value)
예제 #5
0
 def test_quoted_phrase(self):
     self.assertEqual([("word", "Hello, world!")],
                      tokenise("\"Hello, world!\"").value)
예제 #6
0
 def test_quote_character(self):
     for quote in ("\"", "\'"):
         self.assertEqual(
             tokenise(f"{quote}{quote}{quote}{quote}").value,
             [("word", f"{quote}")])
예제 #7
0
 def test_quoted_keyword(self):
     self.assertEqual([("word", "select")], tokenise("\"select\"").value)
예제 #8
0
 def test_split_keyword(self):
     self.assertEqual([("keyword", "order by")], tokenise("order by").value)
예제 #9
0
 def test_empty_word(self):
     self.assertEqual(tokenise("\"\"").value, [("word", "")])
예제 #10
0
 def test_keyword(self):
     self.assertEqual([("keyword", "select")], tokenise("select").value)
예제 #11
0
 def test_multiple_digit(self):
     self.assertEqual([("number", "010")], tokenise("010").value)
예제 #12
0
 def test_single_digit(self):
     self.assertEqual([("number", "7")], tokenise("7").value)
예제 #13
0
 def test_words(self):
     self.assertEqual([("word", "hello"), ("word", "world")],
                      tokenise("hello world").value)
예제 #14
0
 def test_empty(self):
     self.assertEqual([], tokenise("").value)