Commit 23c3d60f authored by Matěj Cepl's avatar Matěj Cepl

Perhaps we don't need unittest2 after all

Bump the release as well.
parent 73501580
......@@ -12,7 +12,7 @@ def read(fname):
setup(
name='yamlish',
version="0.12",
version="0.13",
description='Python implementation of YAMLish',
author='Matěj Cepl',
author_email='mcepl@redhat.com',
......
......@@ -2,18 +2,14 @@
from __future__ import absolute_import, print_function, unicode_literals
import logging
import yamlish
try:
import unittest2 as unittest
except ImportError:
import unittest
import yaml
import tempfile
import textwrap
from textwrap import dedent
INPUT = 1
OUTPUT = 2
def _generate_test_name(source):
"""
Clean up human-friendly test name into a method name.
......@@ -21,6 +17,7 @@ def _generate_test_name(source):
out = source.replace(' ', '_').replace(':', '').replace(',', '').lower()
return "test_%s" % out
def _create_input_test(test_src, tested_function):
"""
Decorate tested function to be used as a method for TestCase.
......@@ -77,10 +74,10 @@ def _create_output_test(test_src, tested_function):
return do_test_expected
def generate_testsuite(test_data, test_case_shell, test_fce, direction=INPUT):
"""
Generate tests from the test data, class to build upon and function to use for testing.
Generate tests from the test data, class to build upon and function
to use for testing.
"""
for in_test in test_data:
if ('skip' in in_test) and in_test['skip']:
......@@ -88,8 +85,8 @@ def generate_testsuite(test_data, test_case_shell, test_fce, direction=INPUT):
continue
name = _generate_test_name(in_test['name'])
if direction == INPUT:
test_method = _create_input_test (in_test, test_fce)
test_method = _create_input_test(in_test, test_fce)
elif direction == OUTPUT:
test_method = _create_output_test(in_test, test_fce)
test_method.__name__ = str('test_%s' % name) # IGNORE:W0622
setattr (test_case_shell, test_method.__name__, test_method)
test_method.__name__ = str('test_%s' % name)
setattr(test_case_shell, test_method.__name__, test_method)
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest
class TestBasics(unittest.TestCase):
def test_import(self):
import yamlish
self.assertTrue(yamlish.__version__,
"Testing import of yamlish, version %s." % yamlish.__version__)
"Testing import of yamlish, version %s."
% yamlish.__version__)
if __name__ == "__main__":
unittest.main()
......@@ -5,14 +5,11 @@ Test general output functionality.
Without much stress on the format itself.
"""
from __future__ import absolute_import, print_function, unicode_literals
try:
import unittest2 as unittest
except ImportError:
import unittest
import yamlish
import yaml
import logging
import tempfile
import unittest
OUT = """---
bill-to:
......@@ -74,6 +71,7 @@ IN = {
'total': 4443.52
}
class TestOuptut(unittest.TestCase):
def setUp(self):
"""
......@@ -81,7 +79,6 @@ class TestOuptut(unittest.TestCase):
"""
self._expected = yaml.safe_load(OUT)
def test_file_output(self):
"""
Test output to a file.
......@@ -95,7 +92,6 @@ class TestOuptut(unittest.TestCase):
got = yaml.safe_load(got_str)
self.assertEqual(got, self._expected, "Result matches")
def test_string_output(self):
"""
Test output to a string.
......
......@@ -3,10 +3,7 @@ from __future__ import absolute_import, print_function, unicode_literals
import yaml
import yamlish
import test
try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest
test_data_list = [
{
......@@ -365,6 +362,7 @@ test_data_list = [
},
]
class TestReader(unittest.TestCase): # IGNORE:C0111
pass
......
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest
import test
import yamlish
......@@ -191,10 +187,12 @@ test_data_list = [
},
]
class TestWriter(unittest.TestCase): # IGNORE:C0111
pass
test.generate_testsuite(test_data_list, TestWriter, yamlish.dump, direction=test.OUTPUT)
test.generate_testsuite(test_data_list, TestWriter, yamlish.dump,
direction=test.OUTPUT)
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment