Просмотр исходного кода

Update contributing docs with pytest commands

master
Michael van Tellingen 10 лет назад
Родитель
Сommit
f02ffa580f
1 измененных файлов: 46 добавлений и 42 удалений
  1. 46
    42
      docs/source/internals/contributing/running-tests.rst

+ 46
- 42
docs/source/internals/contributing/running-tests.rst Просмотреть файл

@@ -5,37 +5,30 @@ Test suite
5 5
 Running tests
6 6
 -------------
7 7
 
8
-Oscar uses a nose_ testrunner which can be invoked using::
8
+Oscar uses pytest_ to run the tests, which can be invoked using::
9 9
 
10 10
     $ ./runtests.py
11 11
 
12
-.. _nose: http://nose.readthedocs.org/en/latest/
12
+.. _pytest: http://pytest.org/latest/
13 13
 
14
-To run a subset of tests, you can use filesystem or module paths.  These two
15
-commands will run the same set of tests::
14
+You can run a subset of the tests by passing a path:
16 15
 
17 16
     $ ./runtests.py tests/unit/offer/availability_tests.py
18
-    $ ./runtests.py tests.unit.offer.availability_tests
19 17
 
20
-To run an individual test class, use one of::
18
+To run an individual test class, use::
21 19
 
22
-    $ ./runtests.py tests/unit/offer/availability_tests.py:TestAPerUserConditionalOffer
23
-    $ ./runtests.py tests.unit.offer.availability_tests:TestAPerUserConditionalOffer
20
+    $ ./runtests.py tests/unit/offer/availability_tests.py::TestASuspendedOffer
24 21
 
25
-(Note the ':'.)
22
+(Note the '::'.)
26 23
 
27
-To run an individual test, use one of::
24
+To run an individual test, use::
28 25
 
29
-    $ ./runtests.py tests/unit/offer/availability_tests.py:TestAPerUserConditionalOffer.test_is_available_with_no_applications
30
-    $ ./runtests.py tests.unit.offer.availability_tests:TestAPerUserConditionalOffer.test_is_available_with_no_applications
26
+    $ ./runtests.py tests/unit/offer/availability_tests.py::TestASuspendedOffer::test_is_unavailable
31 27
 
32
-To check if the number of queries changes::
28
+You can also run tests which match an expression via::
33 29
 
34
-    $ ./runtests.py --with-querycount
30
+    $ ./runtests.py tests/unit/offer/availability_tests.py -k is_unavailable
35 31
 
36
-Please note that ``--with-querycount`` sets ``DEBUG = True``, which might affect
37
-test outcomes. Total query count gives a quick indication. Diff'ing the outputs
38
-is recommended for further analysis.
39 32
 
40 33
 Testing against different setups
41 34
 --------------------------------
@@ -75,28 +68,39 @@ When running a subset of tests, Oscar uses the spec_ plugin.  It is a good
75 68
 practice to name your test cases and methods so that the spec output reads well.
76 69
 For example::
77 70
 
78
-    $ ./runtests.py tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount
79
-    nosetests --verbosity 1 tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount -s -x --with-spec
80
-    Creating test database for alias 'default'...
81
-
82
-    Absolute discount
83
-    - consumes all lines for multi item basket cheaper than threshold
84
-    - consumes all products for heterogeneous basket
85
-    - consumes correct quantity for multi item basket more expensive than threshold
86
-    - correctly discounts line
87
-    - discount is applied to lines
88
-    - gives correct discount for multi item basket cheaper than threshold
89
-    - gives correct discount for multi item basket more expensive than threshold
90
-    - gives correct discount for multi item basket with max affected items set
91
-    - gives correct discount for single item basket cheaper than threshold
92
-    - gives correct discount for single item basket equal to threshold
93
-    - gives correct discount for single item basket more expensive than threshold
94
-    - gives correct discounts when applied multiple times
95
-    - gives correct discounts when applied multiple times with condition
96
-    - gives no discount for a non discountable product
97
-    - gives no discount for an empty basket
98
-
99
-    ----------------------------------------------------------------------
100
-    Ran 15 tests in 0.295s
101
-
102
-.. _spec: https://github.com/bitprophet/spec
71
+    $ py.test tests/integration/catalogue/product_tests.py --spec
72
+    ============================== test session starts ==============================
73
+    platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.7.0
74
+    rootdir: /Users/mvantellingen/projects/django-oscar, inifile: setup.cfg
75
+    plugins: cache, cov, django, spec, xdist
76
+    collected 15 items 
77
+
78
+    tests/integration/catalogue/product_tests.py::ProductCreationTests
79
+        [PASS]  Allow two products without upc
80
+        [PASS]  Create products with attributes
81
+        [PASS]  None upc is represented as empty string
82
+        [PASS]  Upc uniqueness enforced
83
+
84
+    tests/integration/catalogue/product_tests.py::TopLevelProductTests
85
+        [PASS]  Top level products are part of browsable set
86
+        [PASS]  Top level products must have product class
87
+        [PASS]  Top level products must have titles
88
+
89
+    tests/integration/catalogue/product_tests.py::ChildProductTests
90
+        [PASS]  Child products are not part of browsable set
91
+        [PASS]  Child products dont need a product class
92
+        [PASS]  Child products dont need titles
93
+        [PASS]  Child products inherit fields
94
+        [PASS]  Have a minimum price
95
+
96
+    tests/integration/catalogue/product_tests.py::TestAChildProduct
97
+        [PASS]  Delegates requires shipping logic
98
+
99
+    tests/integration/catalogue/product_tests.py::ProductAttributeCreationTests
100
+        [PASS]  Entity attributes
101
+        [PASS]  Validating option attribute
102
+
103
+    =========================== 15 passed in 1.64 seconds ===========================
104
+
105
+
106
+.. _spec: https://pypi.python.org/pypi/pytest-spec

Загрузка…
Отмена
Сохранить