Beispiel #1
0
def test_DictColumnToRowsWithNonDictTuple():
    '''Test if nondict returns None when given a Tuple.'''
    import tableful_utils
    testTuple = ((1, 2, 3), (4, 5, 6), (7, 8, 9))
    expected = None
    rows = tableful_utils._GetDictRows(testTuple)
    assert rows is expected, \
        "Rows were {} but should be None".format(rows, expected)
Beispiel #2
0
def TablefulOfDict(dictionary, *, file=None):
    '''
    Prints a dict in a tableful way!

    keyword args:
    file - any object that can be written to
    '''
    headers = tableful_utils._GetDictHeaders(dictionary)
    rows = tableful_utils._GetDictRows(dictionary)
    Tableful(rows, headers=headers, file=file)
Beispiel #3
0
def TablefulOfDict(dictionary, *, file=None, delim="default"):
    '''
    Prints a dict in a tableful way!

    keyword args:
    file - any object that can be written to
    delim - set to html for an html table
            see docs of Tableful for custom delim settings which are passed through here
    '''
    headers = tableful_utils._GetDictHeaders(dictionary)
    rows = tableful_utils._GetDictRows(dictionary)
    Tableful(rows, headers=headers, file=file, delim=delim)
Beispiel #4
0
def test_DictColumnToRowsWithDict():
    '''Test if _DictColumnsToRows returns rows correctly.'''
    import tableful_utils
    testDict = OrderedDict([
        ('First', [1, 2, 3]),
        ('Second', [4, 5, 6]),
        ('Third', [7, 8, 9])
     ])
    expected = ((1, 4, 7), (2, 5, 8), (3, 6, 9))
    rows = tableful_utils._GetDictRows(testDict)
    assert rows == expected, \
        "Rows were {} but should be {}".format(rows, expected)