1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-05-06 22:07:59 +02:00

fix rstrip and add tests

This commit is contained in:
Kelly Brazil
2022-03-21 19:10:02 -07:00
parent ab564f5be8
commit 53dd05e52c
2 changed files with 29 additions and 1 deletions
+27
View File
@@ -1,5 +1,6 @@
import os
import unittest
from jc.exceptions import ParseError
import jc.parsers.asciitable_m
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -217,6 +218,32 @@ class MyTests(unittest.TestCase):
self.assertEqual(jc.parsers.asciitable_m.parse(input, quiet=True), expected)
def test_asciitable_m_markdown(self):
"""
Test 'asciitable_m' with a markdown table. Should raise a ParseError
"""
input = '''
| type | total | used | free | shared | buff cache | available |
|--------|---------|--------|---------|----------|--------------|-------------|
| Mem | 3861332 | 222820 | 3364176 | 11832 | 274336 | 3389588 |
| Swap | 2097148 | 0 | 2097148 | | | |
'''
self.assertRaises(ParseError, jc.parsers.asciitable_m.parse, input, quiet=True)
def test_asciitable_m_simple(self):
"""
Test 'asciitable_m' with a simple table. Should raise a ParseError
"""
input = '''
type total used free shared buff cache available
------ ------- ------ ------- -------- ------------ -----------
Mem 3861332 222820 3364176 11832 274336 3389588
Swap 2097148 0 2097148
'''
self.assertRaises(ParseError, jc.parsers.asciitable_m.parse, input, quiet=True)
if __name__ == '__main__':
unittest.main()