aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2012-02-27 18:54:37 +0100
committerMatěj Cepl <mcepl@redhat.com>2012-02-27 18:54:37 +0100
commitd9f2aa1f9d1066a168700c4e356db4f26772468a (patch)
treeafe42448063640b6b822e95c032fd649a6be353d /test
parenta9adb2cae3d62d95a1fdc57d7137dca5e5b9ada9 (diff)
downloadyamlish-d9f2aa1f9d1066a168700c4e356db4f26772468a.tar.gz
Temporary commit to make files available
Diffstat (limited to 'test')
-rw-r--r--test/__init__.py13
-rw-r--r--test/all_tests.py23
-rw-r--r--test/test_input.py11
-rw-r--r--test/test_output.py32
-rw-r--r--test/test_reader.py12
5 files changed, 39 insertions, 52 deletions
diff --git a/test/__init__.py b/test/__init__.py
index cb37281..b66ce57 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -5,7 +5,7 @@ from test import test_reader, test_input
import yamlish
import unittest
import yaml
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.INFO)
def _generate_test_name(source):
"""
@@ -55,14 +55,3 @@ def generate_testsuite(test_data, test_case_shell, test_fce):
test_method = _create_test (in_test, test_fce)
test_method.__name__ = str('test_%s' % name) # IGNORE:W0622
setattr (test_case_shell, test_method.__name__, test_method)
-
-class TestInput(unittest.TestCase): # IGNORE:C0111
- pass
-
-class TestReader(unittest.TestCase): # IGNORE:C0111
- pass
-
-if __name__ == "__main__":
- generate_testsuite(test_reader.test_data_list, TestReader, yamlish.load)
- generate_testsuite(test_input.test_data_list, TestInput, yamlish.load)
- unittest.main()
diff --git a/test/all_tests.py b/test/all_tests.py
deleted file mode 100644
index 66e069b..0000000
--- a/test/all_tests.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import sys
-import os.path
-sys.path.insert(0, os.path.realpath(os.path.dirname(__file__) + "/.."))
-
-import logging
-logging.basicConfig(level=logging.INFO)
-import unittest
-import test_load
-import test_input
-import test_reader
-import test_output
-import test_writer
-
-if __name__ == "__main__":
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromModule(test_load)
- #suite.addTests(loader.loadTestsFromModule(test_input))
- suite.addTests(loader.loadTestsFromModule(test_reader))
- #suite.addTests(loader.loadTestsFromModule(test_output))
- #suite.addTests(loader.loadTestsFromModule(test_writer))
-
- runner = unittest.TextTestRunner(verbosity=2)
- result = runner.run(suite)
diff --git a/test/test_input.py b/test/test_input.py
index d950f86..6ed6a6f 100644
--- a/test/test_input.py
+++ b/test/test_input.py
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
+import test
+import unittest
+import yamlish
+
test_data_list = [
{
"name": "Input test",
@@ -64,3 +68,10 @@ total: 4443.52
}
}
]
+
+class TestInput(unittest.TestCase): # IGNORE:C0111
+ pass
+
+if __name__ == "__main__":
+ test.generate_testsuite(test_data_list, TestInput, yamlish.load)
+ unittest.main()
diff --git a/test/test_output.py b/test/test_output.py
index cebd66d..4ed050f 100644
--- a/test/test_output.py
+++ b/test/test_output.py
@@ -44,31 +44,31 @@ IN = {
'given': 'Chris',
'address': {
'city': 'Royal Oak',
- 'postal': '48046',
- 'lines': "458 Walkman Dr.\nSuite #292\n",
+ 'postal': 48046,
+ 'lines': "458 Walkman Dr.\\nSuite #292\\n",
'state': 'MI'
},
'family': 'Dumars'
},
- 'invoice': '34843',
+ 'invoice': 34843,
'date': '2001-01-23',
- 'tax': '251.42',
+ 'tax': 251.42,
'product': [
{
'sku': 'BL394D',
- 'quantity': '4',
- 'price': '450.00',
+ 'quantity': 4,
+ 'price': 450.00,
'description': 'Basketball'
},
{
'sku': 'BL4438H',
- 'quantity': '1',
- 'price': '2392.00',
+ 'quantity': 1,
+ 'price': 2392.00,
'description': 'Super Hoop'
}
],
- 'comments': "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n",
- 'total': '4443.52'
+ 'comments': "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\\n",
+ 'total': 4443.52
}
buf1 = []
@@ -100,10 +100,10 @@ class TestOuptut(unittest.TestCase):
"""
self._expected = ""
for line in OUT:
- self._expected += "%s\n" % line
+ self._expected += line + "\n"
- def test_file_output(self):
+ def notest_file_output(self):
"""
Test output to a file.
"""
@@ -124,10 +124,10 @@ class TestOuptut(unittest.TestCase):
"""
got = yamlish.dumps(IN)
self.assertEqual(got, self._expected, """Result matches
- expected = %s
-
- observed = %s
- """ % (self._expected, got))
+ expected = %s
+
+ observed = %s
+ """ % (self._expected, got))
if __name__ == "__main__":
unittest.main()
diff --git a/test/test_reader.py b/test/test_reader.py
index 79756c9..8c681c8 100644
--- a/test/test_reader.py
+++ b/test/test_reader.py
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
import yaml
+import yamlish
+import test
+import unittest
test_data_list = [
{
@@ -39,7 +42,7 @@ test_data_list = [
},
{
"name": 'Mixed array',
- "in": [ '---', '- 1', "- 'two'", r'- "three\n"', '...', ],
+ "in": [ '---', '- 1', "- 'two'", '- "three\n"', '...', ],
"out": [ 1, 'two', "three\n" ],
},
{
@@ -359,3 +362,10 @@ test_data_list = [
},
},
]
+
+class TestReader(unittest.TestCase): # IGNORE:C0111
+ pass
+
+if __name__ == "__main__":
+ test.generate_testsuite(test_data_list, TestReader, yamlish.load)
+ unittest.main()