testing command line utilities

后端 未结 4 2137
青春惊慌失措
青春惊慌失措 2021-02-14 02:01

I\'m looking for a way to run tests on command-line utilities written in bash, or any other language.

I\'d like to find a testing framework that would have statements li

4条回答
  •  生来不讨喜
    2021-02-14 02:17

    Check out ScriptTest :

    from scripttest import TestFileEnvironment
    
    env = TestFileEnvironment('./scratch')
    
    def test_script():
        env.reset()
        result = env.run('do_awesome_thing testfile --with extra_win --file %s' % filename)
        # or use a list like ['do_awesome_thing', 'testfile', ...]
        assert result.stdout.startswith('Creating awesome file')
        assert filename in result.files_created
    

    It's reasonably doctest-usable as well.

提交回复
热议问题