Sniffer

An automatic test runner. Supports nose out of the box.
Download

Sniffer Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Jeff Hui
  • Publisher web site:
  • http://jeffhui.net

Sniffer Tags


Sniffer Description

An automatic test runner. Supports nose out of the box. sniffer is a autotest tool for Python using the nosetest library.Sniffer will automatically re-run tests if your code changes. And with another third-party library (see below), the CPU usage of file system monitoring is reduced in comparison to pure-python solutions. However, sniffer will still work without any of those libraries.UsageTo install:pip install nosepip install snifferSimply run sniffer in your project directory.You can use sniffer --help for options And like autonose, you can pass the nose arguments: -x--with-doctest or -x--config.The problem with autonose, is that the autodetect can be slow to detect changes. This is due to the pure python implementation - manually walking through the file system to see what's changed. Although the default install of sniffer shares the same problem, installing a third-party library can help fix the problem. The library is dependent on your operating system: * If you use Linux, you'll need to install pyinotify. * If you use Windows, you'll need to install pywin32. * If you use Mac OS X 10.5+ (Leopard), you'll need to install MacFSEvents.As a word of warning, Windows and OSX libraries are untested as of now. This is because I haven't gotten around to testing in Windows, and I don't have a Mac :(.Other UsesRunning with Other Test FrameworksIf you want to run another unit testing framework, you can do so by overriding sniffer.Sniffer, which is the class that handles running tests, or whatever you want. Specifically, you'll want to override the run, method to configure what you need to be done.The property, test_args, are arguments gathered through --config=blah and -x.* configuration options. You should perform you imports inside the function instead of outside, to let the class reload the test framework (and reduce possibilities of multiple-run bugs).After subclassing, set sniffer_cls parameter to your custom class when calling run or main.Using the FileSystem monitoring codeIf you simply want to use the file system monitor code, import sniffer.Scanner. Behind the scenes, the library will figure out what libraries are available to use and which monitor technique to use.Right now, this is lacking some documentation, but here's a small example.Creating the scanner is simple:from sniffer import Scannerpaths = ('/path/to/watch/', '/another/path')scanner = Scanner(paths)Here we pass a tuple of paths to monitor. Now we need to get notification when events occur:# when file is createdscanner.observe('created', lambda path: print "Created", path)# when file is modifiedscanner.observe('modified', lambda path: print "Modified", path)# when file is deletedscanner.observe('deleted', lambda path: print "Deleted", path)# when scanner.loop() is calledscanner.observe('init', lambda: print "Scanner started listening.")In addition, we can use the same function to listen to multiple events:# listen to multiple eventsscanner.observe(('created', 'modified', 'deleted'), lambda path: "Triggered:", path)Finally, we start our blocking loop:# blocksscanner.loop() Requirements: · Python


Sniffer Related Software