Skip to content

Commit f7d0d9c

Browse files
authored
Merge pull request #412 from seleniumbase/update-pytest-discovery-rules
Update pytest discovery rules
2 parents ad31f39 + 7be67de commit f7d0d9c

File tree

8 files changed

+94
-7
lines changed

8 files changed

+94
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb4.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt=" " />](https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master) [<img src="https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master" alt=" " />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt=" " />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/stargazers)
44

examples/swag_labs_suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def login(self, user="standard_user"):
1313
self.update_text("#user-name", user)
1414
self.update_text("#password", "secret_sauce")
1515
self.click('input[type="submit"]')
16-
self.assert_text("Products", "div.product_label")
1716
self.assert_element("#inventory_container")
17+
self.assert_text("Products", "div.product_label")
1818

1919
@parameterized.expand([
2020
["standard_user"],

examples/test_swag_labs.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class SwagLabsTests(BaseCase):
5+
6+
def login(self, user="standard_user"):
7+
""" Login to Swag Labs and assert that the login was successful. """
8+
if user not in (["standard_user", "problem_user"]):
9+
raise Exception("Invalid user!")
10+
self.open("https://www.saucedemo.com/")
11+
self.update_text("#user-name", user)
12+
self.update_text("#password", "secret_sauce")
13+
self.click('input[type="submit"]')
14+
self.assert_element("#inventory_container")
15+
self.assert_text("Products", "div.product_label")
16+
17+
def test_swag_labs_basic_flow(self):
18+
""" This test checks for basic functional flow in the Swag Labs store.
19+
The test is parameterized, and receives the user to use for login.
20+
"""
21+
self.login()
22+
23+
# Verify that the "Test.allTheThings() T-Shirt" appears on the page
24+
item_name = "Test.allTheThings() T-Shirt"
25+
self.assert_text(item_name)
26+
27+
# Verify that a reverse-alphabetical sort works as expected
28+
self.select_option_by_value("select.product_sort_container", "za")
29+
if item_name not in self.get_text("div.inventory_item"):
30+
raise Exception('Sort Failed! Expecting "%s" on top!' % item_name)
31+
32+
# Add the "Test.allTheThings() T-Shirt" to the cart
33+
self.assert_exact_text("ADD TO CART", "button.btn_inventory")
34+
item_price = self.get_text("div.inventory_item_price")
35+
self.click("button.btn_inventory")
36+
self.assert_exact_text("REMOVE", "button.btn_inventory")
37+
self.assert_exact_text("1", "span.shopping_cart_badge")
38+
39+
# Verify your cart
40+
self.click("#shopping_cart_container path")
41+
self.assert_exact_text("Your Cart", "div.subheader")
42+
self.assert_text(item_name, "div.inventory_item_name")
43+
self.assert_exact_text("1", "div.cart_quantity")
44+
self.assert_exact_text("REMOVE", "button.cart_button")
45+
self.assert_element("link=CONTINUE SHOPPING")
46+
47+
# Checkout - Add info
48+
self.click("link=CHECKOUT")
49+
self.assert_exact_text("Checkout: Your Information", "div.subheader")
50+
self.assert_element("a.cart_cancel_link")
51+
self.update_text("#first-name", "SeleniumBase")
52+
self.update_text("#last-name", "Rocks")
53+
self.update_text("#postal-code", "01720")
54+
55+
# Checkout - Overview
56+
self.click("input.btn_primary")
57+
self.assert_exact_text("Checkout: Overview", "div.subheader")
58+
self.assert_element("link=CANCEL")
59+
self.assert_text(item_name, "div.inventory_item_name")
60+
self.assert_text(item_price, "div.inventory_item_price")
61+
self.assert_exact_text("1", "div.summary_quantity")
62+
63+
# Finish Checkout and verify item is no longer in cart
64+
self.click("link=FINISH")
65+
self.assert_exact_text("THANK YOU FOR YOUR ORDER", "h2")
66+
self.assert_element("div.pony_express")
67+
self.click("#shopping_cart_container path")
68+
self.assert_element_absent("div.inventory_item_name")
69+
self.click("link=CONTINUE SHOPPING")
70+
self.assert_element_absent("span.shopping_cart_badge")

help_docs/customizing_test_runs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_m.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

3-
### Customizing test runs with **pytest** (or nosetests)
3+
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Customizing test runs
44

5-
In addition to [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) (which lets you customize SeleniumBase global properties) you can customize test runs from the command line:
5+
In addition to [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) (which lets you customize SeleniumBase global properties) you can customize test runs from the command line with pytest (or nosetests):
66

77
* Choose the browser for tests to use (Default: Chrome)
88
* Choose betweeen pytest & nose unittest runners

help_docs/features_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
<a id="feature_list"></a>
4-
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **SeleniumBase Features:**
4+
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Features:**
55
* A complete test automation framework for building & running reliable testing scripts.
66
* Uses [Pytest](https://docs.pytest.org/en/latest/) and [Nose](http://nose.readthedocs.io/en/latest/) runners for test discovery, organization, execution, and logging.
77
* Includes [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md) that save you time by installing web drivers automatically, etc.

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ addopts = --capture=no --ignore conftest.py -p no:cacheprovider
66
# Ignore warnings such as DeprecationWarning and pytest.PytestUnknownMarkWarning
77
filterwarnings = ignore::pytest.PytestWarning
88

9+
# Set pytest discovery rules:
10+
# (Most of the rules here are similar to the default rules.)
11+
# (unittest.TestCase rules override the rules here for classes and functions.)
12+
python_files = test_*.py *_test.py *_tests.py *_suite.py
13+
python_classes = Test* *Test* *Test *Tests *Suite
14+
python_functions = test_*
15+
916
# Here are the pytest markers used in the example tests:
1017
# (pytest v4.5.0 and newer requires marker registration to prevent warnings.)
1118
# (Future versions of pytest may turn those marker warnings into errors.)

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ def main():
5555
data.append("addopts = --capture=no --ignore conftest.py "
5656
"-p no:cacheprovider")
5757
data.append("filterwarnings = ignore::pytest.PytestWarning")
58+
data.append("python_files = test_*.py *_test.py *_tests.py *_suite.py")
59+
data.append("python_classes = Test* *Test* *Test *Tests *Suite")
60+
data.append("python_functions = test_*")
61+
data.append("markers =")
62+
data.append(" marker1: custom marker")
63+
data.append(" marker2: custom marker")
64+
data.append(" marker3: custom marker")
65+
data.append(" marker_test_suite: custom marker")
66+
data.append(" expected_failure: custom marker")
67+
data.append("")
5868
file_path = "%s/%s" % (dir_name, "pytest.ini")
5969
file = codecs.open(file_path, "w+", "utf-8")
6070
file.writelines("\r\n".join(data))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
setup(
4747
name='seleniumbase',
48-
version='1.32.20',
48+
version='1.32.21',
4949
description='Fast, Easy, and Reliable Browser Automation & Testing.',
5050
long_description=long_description,
5151
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)