opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
nose
/
plugins
/
__pycache__
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
__init__.cpython-312.pyc
6.40 KB
Rename
Delete
allmodules.cpython-312.pyc
2.30 KB
Rename
Delete
attrib.cpython-312.pyc
9.89 KB
Rename
Delete
base.cpython-312.pyc
30.22 KB
Rename
Delete
builtin.cpython-312.pyc
1.16 KB
Rename
Delete
capture.cpython-312.pyc
5.10 KB
Rename
Delete
collect.cpython-312.pyc
4.97 KB
Rename
Delete
cover.cpython-312.pyc
13.92 KB
Rename
Delete
debug.cpython-312.pyc
3.08 KB
Rename
Delete
deprecated.cpython-312.pyc
2.11 KB
Rename
Delete
doctests.cpython-312.pyc
21.00 KB
Rename
Delete
errorclass.cpython-312.pyc
9.29 KB
Rename
Delete
failuredetail.cpython-312.pyc
2.27 KB
Rename
Delete
isolate.cpython-312.pyc
5.18 KB
Rename
Delete
logcapture.cpython-312.pyc
12.53 KB
Rename
Delete
manager.cpython-312.pyc
21.72 KB
Rename
Delete
multiprocess.cpython-312.pyc
38.25 KB
Rename
Delete
plugintest.cpython-312.pyc
17.02 KB
Rename
Delete
prof.cpython-312.pyc
6.64 KB
Rename
Delete
skip.cpython-312.pyc
2.46 KB
Rename
Delete
testid.cpython-312.pyc
11.73 KB
Rename
Delete
xunit.cpython-312.pyc
16.28 KB
Rename
Delete
� ��g�4 � �6 � d Z ddlZddlZddlmZ ddlmZ ddgZddl m Z G d� d e� Z dd l mZ eZ G d� de� Z G d� d e� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zedk( rddlZ ej6 � yy# e$ r ddlmZ Y �rw xY w# e$ r eZY �aw xY w)a_ Testing Plugins =============== The plugin interface is well-tested enough to safely unit test your use of its hooks with some level of confidence. However, there is also a mixin for unittest.TestCase called PluginTester that's designed to test plugins in their native runtime environment. Here's a simple example with a do-nothing plugin and a composed suite. >>> import unittest >>> from nose.plugins import Plugin, PluginTester >>> class FooPlugin(Plugin): ... pass >>> class TestPluginFoo(PluginTester, unittest.TestCase): ... activate = '--with-foo' ... plugins = [FooPlugin()] ... def test_foo(self): ... for line in self.output: ... # i.e. check for patterns ... pass ... ... # or check for a line containing ... ... assert "ValueError" in self.output ... def makeSuite(self): ... class TC(unittest.TestCase): ... def runTest(self): ... raise ValueError("I hate foo") ... return [TC('runTest')] ... >>> res = unittest.TestResult() >>> case = TestPluginFoo('test_foo') >>> _ = case(res) >>> res.errors [] >>> res.failures [] >>> res.wasSuccessful() True >>> res.testsRun 1 And here is a more complex example of testing a plugin that has extra arguments and reads environment variables. >>> import unittest, os >>> from nose.plugins import Plugin, PluginTester >>> class FancyOutputter(Plugin): ... name = "fancy" ... def configure(self, options, conf): ... Plugin.configure(self, options, conf) ... if not self.enabled: ... return ... self.fanciness = 1 ... if options.more_fancy: ... self.fanciness = 2 ... if 'EVEN_FANCIER' in self.env: ... self.fanciness = 3 ... ... def options(self, parser, env=os.environ): ... self.env = env ... parser.add_option('--more-fancy', action='store_true') ... Plugin.options(self, parser, env=env) ... ... def report(self, stream): ... stream.write("FANCY " * self.fanciness) ... >>> class TestFancyOutputter(PluginTester, unittest.TestCase): ... activate = '--with-fancy' # enables the plugin ... plugins = [FancyOutputter()] ... args = ['--more-fancy'] ... env = {'EVEN_FANCIER': '1'} ... ... def test_fancy_output(self): ... assert "FANCY FANCY FANCY" in self.output, ( ... "got: %s" % self.output) ... def makeSuite(self): ... class TC(unittest.TestCase): ... def runTest(self): ... raise ValueError("I hate fancy stuff") ... return [TC('runTest')] ... >>> res = unittest.TestResult() >>> case = TestFancyOutputter('test_fancy_output') >>> _ = case(res) >>> res.errors [] >>> res.failures [] >>> res.wasSuccessful() True >>> res.testsRun 1 � N)�warn)�StringIO�PluginTester�run)�getpidc �<