Package: ptest
ptestptest is a light test framework for Python. With ptest, you can tag test
classes & test cases by decorators, execute test cases by command line,
and get clear reports.Find the latest version on github:https://github.com/KarlGong/ptestor PyPI:https://pypi.org/project/ptestThe documentation is on github wiki:https://github.com/KarlGong/ptest/wiki/documentationInstallationThe last stable release is available on PyPI and can be installed withpip.$ pip install ptestPycharm PluginA Pycharm plugin for ptest is released. Now it is easily to run/debug
ptest within the IDE using the standard run configuration. Find the
latest version on JetBrains:https://plugins.jetbrains.com/plugin/7860Best PracticeFirstly, create a python file:c:\folder\mytest.pyYou can tag test class, test, before method, after method by adding
decorator @TestClass, @Test, @BeforeMethod, @AfterMethod.# c:\folder\mytest.pyfromptest.decoratorimportTestClass,Test,BeforeMethod,AfterMethodfromptest.assertionimportassert_equals,fail,assert_not_nonefromptest.ploggerimportpreporterfromptestimportconfig@TestClass(run_mode="parallel")# the test cases in this class will be executed by multiple threadsclassPTestClass:@BeforeMethod(description="Prepare test data.")defbefore(self):preporter.info("setting expected result.")self.expected=10@Test(tags=["regression","smoke"])deftest1(self):assert_equals(10,self.expected)# pass@Test(tags="smoke, nightly")deftest2(self):assert_not_none(config.get_property("key"))# assert the property defined via -D<key>=<value> in cmd line@Test(enabled=False)# won't be rundeftest3(self):fail("failed")@AfterMethod(always_run=True,description="Clean up")defafter(self):preporter.info("cleaning up")Then start to execute all the testcases in modulemytest.pywith 2
threads. Use-wto specify the workspace,-tto specify the target
and-nto specify the number of test executors(threads). In this case,
workspace isc:\folder, target ismytestand number of test
executors is2.Note:If you are using Windows, please confirm that%python_installation_dir%\Scripts(e.g., C:\Python35\Scripts,
C:\Python37\Scripts) is added to the PATH environment variable.$ ptest -w c:\folder -t mytest -n 2The target can be package/module/class/method. If the target is
package/module/class, all the test cases under target will be executed.
For example, if you only want to execute the testtest1in this
module.$ ptest -w c:\folder -t mytest.PTestClass.test1For more options, please use-h.$ ptest -hFor more code examples, please refer to theexamplesfolder in source
distribution or visithttps://github.com/KarlGong/ptest/tree/master/examplesContact meFor information and suggestions you can contact me atkarl.gong@outlook.comChange Log2.0.3 (compared to 2.0.2)Do not support python 3.52.0.2 (compared to 2.0.1)Do not support python 3.42.0.1 (compared to 2.0.0)Implement f-string to be compatible with python < 3.62.0.0 (compared to 1.9.5)Retire python 2.xSupport preporter log images.1.9.5 (compared to 1.9.4)Support empty data_provider.1.9.4 (compared to 1.9.3)Fix race condition issue.1.9.3 (compared to 1.9.2)Fix that ptest is broken with too many parallel test cases.1.9.2 (compared to 1.9.1)Support callable subject in assert_that assertion.1.9.1 (compared to 1.9.0)Add timestamp for log in html report.1.9.0 (compared to 1.8.2)Add splitter "-" for long command names.1.8.2 (compared to 1.8.1)Support namespace package.1.8.1 (compared to 1.8.0)Add is_all_in, is_any_in, is_none_in to assert_that assertion.1.8.0 (compared to 1.7.7)Support coroutine tests.Support logging extra screenshot by preporter.Optimize html report.1.7.7 (compared to 1.7.6)Optimize assertions.1.7.6 (compared to 1.7.5)Add command option -f(--filter) to filter tests.1.7.5 (compared to 1.7.4)Support customizing data name for @Test.1.7.4 (compared to 1.7.3)Display module info in html report.1.7.3 (compared to 1.7.2)Support displaying webdriver's logs in html report.1.7.2 (compared to 1.7.1)Fix @Test data provider issue in python 3.Fix @Test timeout issue.1.7.1 (compared to 1.7.0)Improve performance of data provider.Fix read property file issue.1.7.0 (compared to 1.6.0)Support data provider for @Test.Fix encoding issue.1.6.0 (compared to 1.5.3)Add meets() in ObjSubject of assert_that assertion.Support taking screenshots for multiple selenium webdrivers.1.5.3 (compared to 1.5.2)Fix the issue that "enabled" attribute for @Test doesn't work.1.5.2 (compared to 1.5.1)Fix install issue by adding CHANGELOG file.1.5.1 (compared to 1.4.3)Add documentation for ptest:https://github.com/KarlGong/ptest/wiki/documentationAdd "assert_that" assertion.Ignore the test group if no group features are used.Support run_group for @TestClass.Support expected_exceptions for @Test.1.4.3 (compared to 1.4.2)Add command option -m(--merge-xunit-xmls) to merge the xunit result xmls.1.4.2 (compared to 1.4.1)Add detailed information for screenshot.1.4.1 (compared to 1.4.0)The instance variables defined in @BeforeSuite, @BeforeClass, @BeforeGroup can be accessed by other test fixtures.Support custom args in test fixtures.Add option (--python-paths) to specify additional python paths.1.4.0 (compared to 1.3.2)Support @BeforeSuite, @BeforeClass, @BeforeGroup, @AfterSuite, @AfterClass, @AfterGroup.Support timeout for test fixtures.Redesign the html report.1.3.2 (compared to 1.3.1)Add cmd line entry points for py3.All temp data will be stored in temp folder.1.3.1 (compared to 1.3.0)Add examples folder.Support declare additional arguments in test methods.1.3.0 (compared to 1.2.2)Support py3.No extra package is needed to capture screenshot.1.2.2 (compared to 1.2.1)Support default value for config.get_property().Add filter for test case status in html report.1.2.1 (compared to 1.2.0)Support multiple test listeners.1.2.0 (compared to 1.1.1)Support run/debug in Pycharm via a ptest plugin.Support filter test cases by group.1.1.0 (compared to 1.0.4)No extra codes are needed to support capturing screenshot for selenium test.Add always_run attribute to @Test.Add command option --disable-screenshot to disable taking screenshot for failed test fixture.Support group in test class.1.0.4 (compared to 1.0.3)Support capture screenshot for no-selenium test.Optimize the html report.