示例#1
0
文件: test.py 项目: hugovk/treestr
 def test_add(self):
     one = t("hello")
     two = t("there")
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIn(one, three.parents)
     self.assertIn(two, three.parents)
示例#2
0
文件: test.py 项目: afcarl/treestr
 def test_add(self):
     one = t("hello")
     two = t("there")
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIn(one, three.parents)
     self.assertIn(two, three.parents)
示例#3
0
文件: test.py 项目: hugovk/treestr
 def test_join(self):
     sep = t(", ")
     one = t("hello")
     two = t("there")
     three = sep.join([one, two])
     self.assertEqual(three, "hello, there")
     self.assertEqual(set(three.parents), set([sep, one, two]))
示例#4
0
文件: test.py 项目: afcarl/treestr
 def test_join(self):
     sep = t(", ")
     one = t("hello")
     two = t("there")
     three = sep.join([one, two])
     self.assertEqual(three, "hello, there")
     self.assertEqual(set(three.parents), set([sep, one, two]))
示例#5
0
文件: test.py 项目: afcarl/treestr
 def test_format(self):
     tmpl = t("this is a {0}")
     fill_in = t("test")
     result = tmpl.format(fill_in)
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
示例#6
0
文件: test.py 项目: hugovk/treestr
 def test_format(self):
     tmpl = t("this is a {0}")
     fill_in = t("test")
     result = tmpl.format(fill_in)
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
示例#7
0
文件: test.py 项目: hugovk/treestr
 def test_mod(self):
     tmpl = t("this is a %s")
     fill_in = t("test")
     result = tmpl % (fill_in,)
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
     result = tmpl % fill_in
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
示例#8
0
文件: test.py 项目: afcarl/treestr
 def test_mod(self):
     tmpl = t("this is a %s")
     fill_in = t("test")
     result = tmpl % (fill_in, )
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
     result = tmpl % fill_in
     self.assertEqual(result, "this is a test")
     self.assertIsInstance(result, t)
     self.assertIn(tmpl, result.parents)
     self.assertIn(fill_in, result.parents)
示例#9
0
文件: test.py 项目: hugovk/treestr
 def test_singles(self):
     # just assume that if "upper()" works, the rest will too
     src = t("hello")
     dest = src.upper()
     self.assertEqual(type(src), t)
     self.assertEqual(type(dest), t)
     self.assertEqual(dest, "HELLO")
     self.assertIn(src, dest.parents)
示例#10
0
文件: test.py 项目: afcarl/treestr
 def test_singles(self):
     # just assume that if "upper()" works, the rest will too
     src = t("hello")
     dest = src.upper()
     self.assertEqual(type(src), t)
     self.assertEqual(type(dest), t)
     self.assertEqual(dest, "HELLO")
     self.assertIn(src, dest.parents)
示例#11
0
文件: test.py 项目: hugovk/treestr
 def test_split(self):
     src = t("a test")
     a, b = src.split(" ")
     self.assertEqual(a, "a")
     self.assertEqual(b, "test")
     self.assertIsInstance(a, t)
     self.assertIsInstance(b, t)
     self.assertIn(src, a.parents)
     self.assertIn(src, b.parents)
示例#12
0
文件: test.py 项目: afcarl/treestr
 def test_split(self):
     src = t("a test")
     a, b = src.split(" ")
     self.assertEqual(a, "a")
     self.assertEqual(b, "test")
     self.assertIsInstance(a, t)
     self.assertIsInstance(b, t)
     self.assertIn(src, a.parents)
     self.assertIn(src, b.parents)
示例#13
0
文件: test.py 项目: afcarl/treestr
 def test_partition(self):
     src = t("it was the best of times, it was the worst of times")
     a, b, c = src.partition(', ')
     self.assertEqual(a, "it was the best of times")
     self.assertEqual(b, ", ")
     self.assertEqual(c, "it was the worst of times")
     self.assertIsInstance(a, t)
     self.assertIsInstance(b, t)
     self.assertIsInstance(c, t)
     self.assertIn(src, a.parents)
     self.assertIn(src, b.parents)
     self.assertIn(src, c.parents)
示例#14
0
文件: test.py 项目: hugovk/treestr
 def test_partition(self):
     src = t("it was the best of times, it was the worst of times")
     a, b, c = src.partition(', ')
     self.assertEqual(a, "it was the best of times")
     self.assertEqual(b, ", ")
     self.assertEqual(c, "it was the worst of times")
     self.assertIsInstance(a, t)
     self.assertIsInstance(b, t)
     self.assertIsInstance(c, t)
     self.assertIn(src, a.parents)
     self.assertIn(src, b.parents)
     self.assertIn(src, c.parents)
示例#15
0
文件: test.py 项目: afcarl/treestr
 def test_getitem(self):
     src = t("magnolia")
     substr = src[1:-1]
     self.assertEqual(substr, "agnoli")
     self.assertIn(src, substr.parents)
示例#16
0
文件: test.py 项目: afcarl/treestr
 def test_radd(self):
     one = "hello"
     two = t("there")
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIsInstance(three, t)
示例#17
0
文件: test.py 项目: afcarl/treestr
 def test_rmul(self):
     src = t("hello")
     dest = 5 * src
     self.assertEqual(dest, "hellohellohellohellohello")
     self.assertIsInstance(dest, t)
示例#18
0
文件: test.py 项目: hugovk/treestr
 def test_parents_from_args(self):
     src = t("hello")
     fillch = t("*")
     dest = src.center(25, fillch)
     self.assertIn(src, dest.parents)
     self.assertIn(fillch, dest.parents)
示例#19
0
文件: test.py 项目: afcarl/treestr
 def test_add_with_str(self):
     one = t("hello")
     two = "there"
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIsInstance(three, t)
示例#20
0
文件: test.py 项目: hugovk/treestr
 def test_rmul(self):
     src = t("hello")
     dest = 5 * src
     self.assertEqual(dest, "hellohellohellohellohello")
     self.assertIsInstance(dest, t)
示例#21
0
文件: test.py 项目: hugovk/treestr
 def test_getitem(self):
     src = t("magnolia")
     substr = src[1:-1]
     self.assertEqual(substr, "agnoli")
     self.assertIn(src, substr.parents)
示例#22
0
文件: test.py 项目: afcarl/treestr
 def test_rtags(self):
     a = t("one", tags={'test1'})
     b = t("two", tags={'test2'})
     c = t("three", tags={'test3'}, parents=(a, b))
     d = t("four", parents=(c, ))
     self.assertEqual(d.rtags(), {'test1', 'test2', 'test3'})
示例#23
0
文件: test.py 项目: hugovk/treestr
 def test_rtags(self):
     a = t("one", tags={'test1'})
     b = t("two", tags={'test2'})
     c = t("three", tags={'test3'}, parents=(a, b))
     d = t("four", parents=(c,))
     self.assertEqual(d.rtags(), {'test1', 'test2', 'test3'})
示例#24
0
文件: test.py 项目: hugovk/treestr
 def test_add_with_str(self):
     one = t("hello")
     two = "there"
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIsInstance(three, t)
示例#25
0
文件: test.py 项目: afcarl/treestr
 def test_parents_from_args(self):
     src = t("hello")
     fillch = t("*")
     dest = src.center(25, fillch)
     self.assertIn(src, dest.parents)
     self.assertIn(fillch, dest.parents)
示例#26
0
文件: test.py 项目: hugovk/treestr
 def test_radd(self):
     one = "hello"
     two = t("there")
     three = one + two
     self.assertEqual(three, "hellothere")
     self.assertIsInstance(three, t)