i3pystatus
i3pystatus copied to clipboard
Testing modifications/additions to modules
I'm trying to add a click event to an existing module (temp.py). I cloned the repo and made changes there. How do I test the changes I've made?
I usually just run i3pystatus straight from the git repo. When I want to test changes to a module I'll just reload i3 to make them take effect. I'd be interested to hear if anyone has any clever ways of testing though.
Development environment: Use a virtualenv (per project)
Testing: running from the virtualenv, either i3pystatus / a test script or the unit tests (classic unit testing would be a mocking orgy for many modules in this project so most modules are only practically tested and not covered by unit tests)
I usually install projects relying on distutils via:
python setup.py develop --user
This creates symlinks and let your package correctly discover python namespaces.
@facetoe I'm pretty sure Ipip installed
or apt-get installed
and I also git cloned... How do I run i3pystatus from the git cloned location?
@211217613 I'd uninstall the code installed from apt and pip then use setup.py
as teto suggests above.
@211217613 Running python from git repo directory should do the trick.
Ipython for ilustration:
In [1]: cd '~/git/i3pystatus/'
/home/luck/git/i3pystatus
In [2]: import i3pystatus
In [3]: i3pystatus?
Type: module
String form: <module 'i3pystatus' from '/home/luck/git/i3pystatus/i3pystatus/__init__.py'>
File: ~/git/i3pystatus/i3pystatus/__init__.py
Docstring: <no docstring>
Something usable in i3 config file:
bar {
status_command bash -c 'cd /home/luck/git/i3pystatus && python testing_config.py'
}
Just make sure that your testing_config.py
is an actuall file inside the git repo directory and not a symlink.
EDIT: Also a method how to test changes that was not mentioned yet: Modify end of your testing_config.py file to look like this:
if __name__ == "__main__":
status.run()
then run ipython from repo directory and import testing_config
In [1]: from testing_config import *
In [2]: status.modules[2]
Out[2]: <i3pystatus.clock.Clock at 0x7fb65327e160>
In [3]: status.modules[2].run(); status.modules[2].output
Out[3]: {'color': '#ffffff', 'full_text': 'Po 23 máj 13:14:35', 'urgent': False}