Monitor refactoring progressing nicely

2 views
Skip to first unread message

Olof Bjarnason

unread,
May 13, 2012, 4:51:38 AM5/13/12
to pytd...@googlegroups.com
I've had two-three nights of "hard refactoring" of pytddmon now, to integrate the Monitor.

Once I started thinking about it, quite a lot of stuff could be removed from the code because of this class:

1. All hashing-stuff was unnecessary
2. That in turn changed all Strategy-classes quite a lot
3. The Regex-strategy really covers all other use cases (static file set, wildcard matching), so I renamed it to "FileFinder" and removed the others
4. Lots of unit tests could be removed (actually only test_monitor and test_color_picker is left. I'm looking at adding unit tests for Pytddmon class though)
5. Lots more small changes, like making the output log more readable.

To make a long story short, "pytddmon.py" went down from 800 lines of code to 550 lines of code, or more than 30% of the production code removed. It's probably even more regarding the unit tests. :).

I'm quite happy about that, because suddenly the code is almost possible to grasp again!

Since it was a brutal refactoring, I did it on a separate fork of objarni/pytddmon:
https://bitbucket.org/objarni/pytddmon_monitor_integration

What is left?
- Well the systests are broken at the moment.
- I've tried to write Python3.x compatible code, but I haven't tested it. Tested on 2.7.

Here's an example of the new log output:

"""
Monitoring folder tests.
Found 4 files.
Last change detected at 10:26:07.
Test run took 0.32 seconds.


Log from pytddmon:
.
----------------------------------------------------------------------
Ran 1 test in 0.004s

OK

Log from __init__:

----------------------------------------------------------------------
Ran 0 tests in 0.001s

OK

Log from test_monitor:
......
----------------------------------------------------------------------
Ran 6 tests in 0.001s

OK

Log from test_color_picker:
.........
----------------------------------------------------------------------
Ran 9 tests in 0.000s

OK
"""



Olof Bjarnason

unread,
May 18, 2012, 5:23:15 PM5/18/12
to pytd...@googlegroups.com
OK I've now managed to get all systests working again:

> python systest.py

.. reports no errors.

However, since the new logic is "run *all* .py files as tests recursively", "python pytddmon.py" tries to run the systests (which are python scripts after all, but not unittests!). But they're stored in non-package folders (no __init__.py file in their directories), so lots of errors are generated (17 to be precise).

A way around that might be to make the systests real unit tests in the Python unittest sense. That is, let pytddmon end-to-end test itself -- it should be possible in theory at least. That would mean we could get rid of both systest.py and all the expected.log-weirdness.

Anyone up for the challenge? ;)

https://bitbucket.org/objarni/pytddmon_monitor_integration

2012/5/13 Olof Bjarnason <olof.bj...@gmail.com>
Reply all
Reply to author
Forward
0 new messages