3 new revisions:
Revision: cacb48a91369
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:48:36 2011
Log: test_parser: nosetests translated to normal unittest
http://code.google.com/p/robotframework/source/detail?r=cacb48a91369
Revision: 4bfe8657b7cb
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:49:06 2011
Log: Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=4bfe8657b7cb
Revision: a6ae0617aca7
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:51:11 2011
Log: test_parser refactoring
http://code.google.com/p/robotframework/source/detail?r=a6ae0617aca7
==============================================================================
Revision: cacb48a91369
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:48:36 2011
Log: test_parser: nosetests translated to normal unittest
http://code.google.com/p/robotframework/source/detail?r=cacb48a91369
Modified:
/utest/result/test_parser.py
=======================================
--- /utest/result/test_parser.py Wed Jun 15 09:24:29 2011
+++ /utest/result/test_parser.py Thu Jun 16 05:48:36 2011
@@ -1,61 +1,7 @@
-# TODO: Are these tests run somehow?????????????????
-
+import unittest
import robot.result.jsparser as jsparser
-def test_timestamp():
- context = jsparser.Context()
- time = context.timestamp('20110603 12:00:00.000')
- assert time == 0
- time = context.timestamp('N/A')
- assert time == -1
- time = context.timestamp('20110603 12:00:01.000')
- assert time == 1000
-
-def test_stats_when_failing_suite_teardown():
- context = jsparser.Context()
- context.collect_stats()
- context.add_test(1,1)
- child_stats = context.dump_stats()
- assert child_stats == [1, 1, 1, 1]
- context.teardown_failed()
- parent_stats = context.dump_stats()
- assert child_stats == [1, 0, 1, 0]
- assert parent_stats == [1, 0, 1, 0]
-
-def test_link_creation():
- key = [4,'W',6]
- context = jsparser.Context()
- context.start_suite("Foo")
- context.start_suite("Bar")
- context.start_test("Zoo")
- context.start_keyword()
- context.create_link_to_current_location(key)
- context.end_keyword()
- context.end_test()
- context.end_suite()
- context.end_suite()
- link = context.link_to(key)
- assert link == "keyword_Foo.Bar.Zoo.0"
-
-def test_2_links():
- key1 = [1,'W',2]
- key2 = [2,'W',5]
- context = jsparser.Context()
- context.start_suite("Bar")
- _kw(context, lambda ctx: ctx.create_link_to_current_location(key1))
- context.start_test("Test")
- context.start_keyword()
- _kw(context)
- _kw(context, lambda ctx: ctx.create_link_to_current_location(key2))
- context.end_keyword()
- context.end_test()
- context.end_suite()
- link2 = context.link_to(key2)
- link1 = context.link_to(key1)
- assert link1 == "keyword_Bar.0"
- assert link2 == "keyword_Bar.Test.0.1"
-
def _kw(context, inner_func=None):
context.start_keyword()
if inner_func: inner_func(context)
@@ -67,40 +13,95 @@
func(context)
return and_func
-def test_link_to_subkeyword():
- key = [1, 'W', 542]
- context = jsparser.Context()
- context.start_suite("Boo") #suite_Boo
- context.start_test("Goo") #test_Boo.Goo
- _kw(context) #keyword_Boo.Goo.0
- _kw(context, _and(_kw, _kw, _kw)) #keyword_Boo.Goo.1.[0,1,2]
- context.start_keyword() #keyword_Boo.Goo.2
- _kw(context) #keyword_Boo.Goo.2.0
- context.start_keyword() #keyword_Boo.Goo.2.1
- context.create_link_to_current_location(key)
- _kw(context) #keyword_Boo.Goo.2.1
- _kw(context) #keyword Boo.Goo.2.2
- context.end_keyword()
- context.end_test()
- context.end_suite()
- link = context.link_to(key)
- assert link == "keyword_Boo.Goo.2.1"
-
-def test_link_to_suite_teardown():
- pkey = [5, 'W', 321]
- skey = [4, 'W', 3214]
- context = jsparser.Context()
- context.start_suite("Suit")
- _kw(context) #Suite setup
- context.start_suite("Subsuite")
- context.start_test("Test1")
- _kw(context)
- context.end_test()
- _kw(context, lambda ctx: ctx.create_link_to_current_location(skey))
- context.end_suite()
- _kw(context, lambda ctx: ctx.create_link_to_current_location(pkey))
- context.end_suite()
- link1 = context.link_to(skey)
- link2 = context.link_to(pkey)
- assert link1 == "keyword_Suit.Subsuite.0"
- assert link2 == "keyword_Suit.1"
+class TestParser(unittest.TestCase):
+
+ def setUp(self):
+ self._context = jsparser.Context()
+
+ def test_timestamp(self):
+ self.assertEqual(self._context.timestamp('20110603 12:00:00.000'),
0)
+ self.assertEqual(self._context.timestamp('20110603 12:00:01.000'),
1000)
+
+ def test_NA_timestamp(self):
+ self.assertEqual(self._context.timestamp('N/A'), None)
+
+ def test_stats_when_failing_suite_teardown(self):
+ context = jsparser.Context()
+ context.collect_stats()
+ context.add_test(1,1)
+ child_stats = context.dump_stats()
+ self.assertEqual(child_stats, [1, 1, 1, 1])
+ context.teardown_failed()
+ parent_stats = context.dump_stats()
+ self.assertEqual(child_stats, [1, 0, 1, 0])
+ self.assertEqual(parent_stats, [1, 0, 1, 0])
+
+ def test_link_creation(self):
+ key = [4,'W',6]
+ self._create_data_and_link(key)
+
self.assertEqual(self._context.link_to(key), 'keyword_Foo.Bar.Zoo.0')
+
+ def _create_data_and_link(self, key):
+ self._context.start_suite('Foo')
+ self._context.start_suite('Bar')
+ self._context.start_test('Zoo')
+ self._context.start_keyword()
+ self._context.create_link_to_current_location(key)
+ self._context.end_keyword()
+ self._context.end_test()
+ self._context.end_suite()
+ self._context.end_suite()
+
+ def test_2_links(self):
+ key1 = [1,'W',2]
+ key2 = [2,'W',5]
+ self._create_data_for_links(key1, key2)
+ self.assertEqual(self._context.link_to(key1), 'keyword_Bar.0')
+
self.assertEqual(self._context.link_to(key2), 'keyword_Bar.Test.0.1')
+
+ def _create_data_for_links(self, key1, key2):
+ self._context.start_suite('Bar')
+ _kw(self._context, lambda ctx:
ctx.create_link_to_current_location(key1))
+ self._context.start_test('Test')
+ self._context.start_keyword()
+ _kw(self._context)
+ _kw(self._context, lambda ctx:
ctx.create_link_to_current_location(key2))
+ self._context.end_keyword()
+ self._context.end_test()
+ self._context.end_suite()
+
+ def test_link_to_subkeyword(self):
+ key = [1, 'W', 542]
+ self._create_data_for_subkeyword(key)
+ self.assertEqual(self._context.link_to(key), 'keyword_Boo.Goo.2.1')
+
+ def _create_data_for_subkeyword(self, key):
+ self._context.start_suite('Boo') #suite_Boo
+ self._context.start_test('Goo') #test_Boo.Goo
+ _kw(self._context) #keyword_Boo.Goo.0
+ _kw(self._context, _and(_kw, _kw, _kw)) #keyword_Boo.Goo.1.[0,1,2]
+ self._context.start_keyword() #keyword_Boo.Goo.2
+ _kw(self._context) #keyword_Boo.Goo.2.0
+ self._context.start_keyword() #keyword_Boo.Goo.2.1
+ self._context.create_link_to_current_location(key)
+ _kw(self._context) #keyword_Boo.Goo.2.1
+ _kw(self._context) #keyword_Boo.Goo.2.2
+ self._context.end_keyword()
+ self._context.end_test()
+ self._context.end_suite()
+
+ def test_link_to_suite_teardown(self):
+ pkey = [5, 'W', 321]
+ skey = [4, 'W', 3214]
+ self._context.start_suite('Suit')
+ _kw(self._context) #Suite setup
+ self._context.start_suite('Subsuite')
+ self._context.start_test('Test1')
+ _kw(self._context)
+ self._context.end_test()
+ _kw(self._context, lambda ctx:
ctx.create_link_to_current_location(skey))
+ self._context.end_suite()
+ _kw(self._context, lambda ctx:
ctx.create_link_to_current_location(pkey))
+ self._context.end_suite()
+
self.assertEqual(self._context.link_to(skey),'keyword_Suit.Subsuite.0')
+ self.assertEqual(self._context.link_to(pkey), 'keyword_Suit.1')
==============================================================================
Revision: 4bfe8657b7cb
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:49:06 2011
Log: Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=4bfe8657b7cb
==============================================================================
Revision: a6ae0617aca7
Author: Mikko Korpela <[email protected]>
Date: Thu Jun 16 05:51:11 2011
Log: test_parser refactoring
http://code.google.com/p/robotframework/source/detail?r=a6ae0617aca7
Modified:
/utest/result/test_parser.py
=======================================
--- /utest/result/test_parser.py Thu Jun 16 05:48:36 2011
+++ /utest/result/test_parser.py Thu Jun 16 05:51:11 2011
@@ -93,6 +93,11 @@
def test_link_to_suite_teardown(self):
pkey = [5, 'W', 321]
skey = [4, 'W', 3214]
+ self._create_data_for_suite_teardown_links(pkey, skey)
+
self.assertEqual(self._context.link_to(skey),'keyword_Suit.Subsuite.0')
+ self.assertEqual(self._context.link_to(pkey), 'keyword_Suit.1')
+
+ def _create_data_for_suite_teardown_links(self, pkey, skey):
self._context.start_suite('Suit')
_kw(self._context) #Suite setup
self._context.start_suite('Subsuite')
@@ -103,5 +108,3 @@
self._context.end_suite()
_kw(self._context, lambda ctx:
ctx.create_link_to_current_location(pkey))
self._context.end_suite()
-
self.assertEqual(self._context.link_to(skey),'keyword_Suit.Subsuite.0')
- self.assertEqual(self._context.link_to(pkey), 'keyword_Suit.1')