Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Sniffer 0.2.6

    Download button

    No screenshots available
    Downloads: 292  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Jeff Hui | More programs
    MIT/X Consortium Lic... / FREE
    August 2nd, 2012, 19:03 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    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.

    Usage

    To install:

    pip install nose
    pip install sniffer


    Simply 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 Uses

    Running with Other Test Frameworks

    If 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 code

    If 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 Scanner

    paths = ('/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 created
    scanner.observe('created', lambda path: print "Created", path)

    # when file is modified
    scanner.observe('modified', lambda path: print "Modified", path)

    # when file is deleted
    scanner.observe('deleted', lambda path: print "Deleted", path)

    # when scanner.loop() is called
    scanner.observe('init', lambda: print "Scanner started listening.")

    In addition, we can use the same function to listen to multiple events:

    # listen to multiple events
    scanner.observe(('created', 'modified', 'deleted'), lambda path: "Triggered:", path)


    Finally, we start our blocking loop:

    # blocks
    scanner.loop()



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    test runner | re-run tests | test | runner | testing

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM