Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for table command no longer work #94

Open
pfuntner opened this issue Apr 22, 2022 · 1 comment
Open

Tests for table command no longer work #94

pfuntner opened this issue Apr 22, 2022 · 1 comment

Comments

@pfuntner
Copy link
Owner

I was revisiting some tests I had done for my table command and it was no longer working:

$ repos/toys/test/table/test.py
Testing df
2022-04-22 07:19:08,257 CRITICAL repos/toys/test/table/test.py:41 xml -> xml mismatch
$ repos/toys/test/table/test.py -v
2022-04-22 07:19:11,919 DEBUG repos/toys/test/table/test.py:55 repos/toys/test/table/../../bin/table.py: True
2022-04-22 07:19:12,088 DEBUG repos/toys/test/table/test.py:18 ['repos/toys/test/table/../../bin/table.py', '--help']: 0, 'usage: table.py [-h] [-H] [-l] -i\n                {xml,csv,flat,form,json,yaml,separator,fixed} -o\n                {xml,csv,flat,form,json,yaml,separator,fixed,html,markdown,bbcode}\n                [-c COLUMNS] [--order ORDER] [-r REGEXP] [-s SEPARATOR]\n                [--sort SORT] [-n] [--style {flow,block}] [--rotate] [-f FILE]\n                [-v]\n\nProcess tabulur data in several input and output formats\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -H, --headings        Treat row 1 as headings\n  -l, --loose-headings  Use all rows to determine column widths\n  -i {xml,csv,flat,form,json,yaml,separator,fixed}, --input {xml,csv,flat,form,json,yaml,separator,fixed}\n                        Input method\n  -o {xml,csv,flat,form,json,yaml,separator,fixed,html,markdown,bbcode}, --output {xml,csv,flat,form,json,yaml,separator,fixed,html,markdown,bbcode}\n                        Output method\n  -c COLUMNS, --columns COLUMNS\n                        Number of columns for the flat format\n  --order ORDER         Specify the order of columns\n  -r REGEXP, --regexp REGEXP\n                        Regular expression to be used as an input separator\n  -s SEPARATOR, --separator SEPARATOR\n                        Output separator\n  --sort SORT           Sort rows by one or more columns\n  -n, --numeric_justify\n                        Right-justify numeric columns during fixed format\n                        output\n  --style {flow,block}  Specify an yaml output style\n  --rotate              Rotate so rows are columns, columns are rows\n  -f FILE, --file FILE  File from which to read, instead of stdin\n  -v, --verbose         Enable debugging\n', ''
2022-04-22 07:19:12,089 DEBUG repos/toys/test/table/test.py:62 methods: {'input': ['xml', 'csv', 'flat', 'form', 'json', 'yaml', 'separator', 'fixed'], 'style': ['flow', 'block'], 'output': ['xml', 'csv', 'flat', 'form', 'json', 'yaml', 'separator', 'fixed', 'html', 'markdown', 'bbcode']}
Testing df
2022-04-22 07:19:12,492 DEBUG repos/toys/test/table/test.py:18 ['repos/toys/test/table/../../bin/table.py', '-i', 'fixed', '-o', 'xml']: 0, '<table><row><col00000000>Filesystem</col00000000><col00000001>1K-blocks</col00000001><col00000002>Used</col00000002><col00000003>Available</col00000003><col00000004>Use%</col00000004><col00000005>Mounted on</col00000005></row><row><col00000000>udev</col00000000><col00000001>8133736</col00000001><col00000002>0</col00000002><col00000003>8133736</col00000003><col00000004>0%</col00000004><col00000005>/dev</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631580</col00000001><col00000002>2156</col00000002><col00000003>1629424</col00000003><col00000004>1%</col00000004><col00000005>/run</col00000005></row><row><col00000000>/dev/sdb2</col00000000><col00000001>236102400</col00000001><col00000002>78900724</col00000002><col00000003>145185244</col00000003><col00000004>36%</col00000004><col00000005>/</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>8157884</col00000001><col00000002>170352</col00000002><col00000003>7987532</col00000003><col00000004>3%</col00000004><col00000005>/dev/shm</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>5120</col00000001><col00000002>4</col00000002><col00000003>5116</col00000003><col00000004>1%</col00000004><col00000005>/run/lock</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>8157884</col00000001><col00000002>0</col00000002><col00000003>8157884</col00000003><col00000004>0%</col00000004><col00000005>/sys/fs/cgroup</col00000005></row><row><col00000000>/dev/loop0</col00000000><col00000001>304256</col00000001><col00000002>304256</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/pycharm-community/128</col00000005></row><row><col00000000>/dev/loop1</col00000000><col00000001>304256</col00000001><col00000002>304256</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/pycharm-community/132</col00000005></row><row><col00000000>/dev/loop2</col00000000><col00000001>8704</col00000001><col00000002>8704</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/canonical-livepatch/77</col00000005></row><row><col00000000>/dev/loop3</col00000000><col00000001>147840</col00000001><col00000002>147840</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/63</col00000005></row><row><col00000000>/dev/loop4</col00000000><col00000001>150912</col00000001><col00000002>150912</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/66</col00000005></row><row><col00000000>/dev/loop5</col00000000><col00000001>90624</col00000001><col00000002>90624</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/core/7270</col00000005></row><row><col00000000>/dev/loop6</col00000000><col00000001>145280</col00000001><col00000002>145280</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/60</col00000005></row><row><col00000000>/dev/loop8</col00000000><col00000001>8704</col00000001><col00000002>8704</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/canonical-livepatch/81</col00000005></row><row><col00000000>/dev/loop7</col00000000><col00000001>90624</col00000001><col00000002>90624</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/core/7169</col00000005></row><row><col00000000>/dev/sda1</col00000000><col00000001>1922727728</col00000001><col00000002>89147392</col00000002><col00000003>1833563952</col00000003><col00000004>5%</col00000004><col00000005>/media/mrbruno/ExtraDrive1</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631576</col00000001><col00000002>16</col00000002><col00000003>1631560</col00000003><col00000004>1%</col00000004><col00000005>/run/user/125</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631576</col00000001><col00000002>60</col00000002><col00000003>1631516</col00000003><col00000004>1%</col00000004><col00000005>/run/user/1000</col00000005></row></table>\n', ''
2022-04-22 07:19:12,492 DEBUG repos/toys/test/table/test.py:27 repos/toys/test/table/df/xml exists: True
2022-04-22 07:19:12,493 DEBUG repos/toys/test/table/test.py:27 repos/toys/test/table/df/xml/xml exists: True
2022-04-22 07:19:12,781 DEBUG repos/toys/test/table/test.py:18 ['repos/toys/test/table/../../bin/table.py', '--regexp', '\\|', '-i', 'xml', '-o', 'xml']: 0, '<table><row><col00000000>Filesystem</col00000000><col00000001>1K-blocks</col00000001><col00000002>Used</col00000002><col00000003>Available</col00000003><col00000004>Use%</col00000004><col00000005>Mounted on</col00000005></row><row><col00000000>udev</col00000000><col00000001>8133736</col00000001><col00000002>0</col00000002><col00000003>8133736</col00000003><col00000004>0%</col00000004><col00000005>/dev</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631580</col00000001><col00000002>2156</col00000002><col00000003>1629424</col00000003><col00000004>1%</col00000004><col00000005>/run</col00000005></row><row><col00000000>/dev/sdb2</col00000000><col00000001>236102400</col00000001><col00000002>78900724</col00000002><col00000003>145185244</col00000003><col00000004>36%</col00000004><col00000005>/</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>8157884</col00000001><col00000002>170352</col00000002><col00000003>7987532</col00000003><col00000004>3%</col00000004><col00000005>/dev/shm</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>5120</col00000001><col00000002>4</col00000002><col00000003>5116</col00000003><col00000004>1%</col00000004><col00000005>/run/lock</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>8157884</col00000001><col00000002>0</col00000002><col00000003>8157884</col00000003><col00000004>0%</col00000004><col00000005>/sys/fs/cgroup</col00000005></row><row><col00000000>/dev/loop0</col00000000><col00000001>304256</col00000001><col00000002>304256</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/pycharm-community/128</col00000005></row><row><col00000000>/dev/loop1</col00000000><col00000001>304256</col00000001><col00000002>304256</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/pycharm-community/132</col00000005></row><row><col00000000>/dev/loop2</col00000000><col00000001>8704</col00000001><col00000002>8704</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/canonical-livepatch/77</col00000005></row><row><col00000000>/dev/loop3</col00000000><col00000001>147840</col00000001><col00000002>147840</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/63</col00000005></row><row><col00000000>/dev/loop4</col00000000><col00000001>150912</col00000001><col00000002>150912</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/66</col00000005></row><row><col00000000>/dev/loop5</col00000000><col00000001>90624</col00000001><col00000002>90624</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/core/7270</col00000005></row><row><col00000000>/dev/loop6</col00000000><col00000001>145280</col00000001><col00000002>145280</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/skype/60</col00000005></row><row><col00000000>/dev/loop8</col00000000><col00000001>8704</col00000001><col00000002>8704</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/canonical-livepatch/81</col00000005></row><row><col00000000>/dev/loop7</col00000000><col00000001>90624</col00000001><col00000002>90624</col00000002><col00000003>0</col00000003><col00000004>100%</col00000004><col00000005>/snap/core/7169</col00000005></row><row><col00000000>/dev/sda1</col00000000><col00000001>1922727728</col00000001><col00000002>89147392</col00000002><col00000003>1833563952</col00000003><col00000004>5%</col00000004><col00000005>/media/mrbruno/ExtraDrive1</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631576</col00000001><col00000002>16</col00000002><col00000003>1631560</col00000003><col00000004>1%</col00000004><col00000005>/run/user/125</col00000005></row><row><col00000000>tmpfs</col00000000><col00000001>1631576</col00000001><col00000002>60</col00000002><col00000003>1631516</col00000003><col00000004>1%</col00000004><col00000005>/run/user/1000</col00000005></row></table>\n', ''
2022-04-22 07:19:12,782 CRITICAL repos/toys/test/table/test.py:41 xml -> xml mismatch
$

I vaguely remember spending some time setting up various scenarios and when I look at what I did, I have a large number of data files - I think the intent was to test translation from method 1 to method 2.

I tried to patch the script a little by removing exits so the script would continue after errors, to try to test as many scenarios as possible, regardless of failures but I would just get stopped by other problems. I decided not to make any commits today. Part of the problem is I may have introduced methods (such as flat) for which I don't have tests.

I wonder how difficult it would be to test the script with pytest.

Additionally, I focused a lot on making sure the data is translated as expected but I'm overlooking options such as --rotate, --order, etc.

@pfuntner
Copy link
Owner Author

This could be a dupe of #107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant