Test Driven Development

EZTable provides a testing mixin called TableTestMixin which can be used to provide more helpful table output:

import unittest
from eztable import table_literal, TableTestMixin


class ExampleTest(TableTestMixin, unittest.TestCase):

    """An example of how to do test-driven
    development with toytable.
    """

    def test_foo(self):
        t0 = table_literal("""
            | A (int) | B (int) | C (str) |
            | 1       | 2       | 3       |
            | 2       | 3       | 4       |
        """)

        t1 = table_literal("""
            | A (int) | B (int) | C (str) |
            | 1       | 2       | 3       |
            | 999     | 3       | 4       |
        """)

        self.assertTablesEqual(t0, t1)

if __name__ == '__main__':
    unittest.main()

EZTable can be used as an alternative to Lettuce style tests.

Testing Mixin

class eztable.TableTestMixin[source]

Bases: object

Mix this class into any unit test test-cases in order to add methods for asserting equality on eztable.Table objects.

Typically the class definition for a unittest will look something like this:

class ExampleTestCase(TableTestMixin, unittest.TestCase):
    ...
assertTablesEqual(A, B, msg=None)[source]

Verfy that two tables are exactly equal. Raises an AssertionError if not.

assertTablesEqualAnyOrder(A, B, msg=None)[source]

Verify that two tables contain the exact same set of rows. Rows may be in any order. Raises an AssertionError the sets of rows are different.

assertTablesEquals(A, B, msg=None)

Verfy that two tables are exactly equal. Raises an AssertionError if not.

assertTablesNotEquals(A, B, msg=None)[source]

Verify that two tables are not equal. Raises an AssertionError if the two tables are equal.