Skip to content

Commit 171becb

Browse files
committed
feat: configure ruff and format files
1 parent 3170092 commit 171becb

10 files changed

Lines changed: 199 additions & 31 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ target
77
.pydevproject
88

99
# VSCode IDE
10-
.vscode
10+
.vscode/*
11+
!.vscode/settings.json
12+
!.vscode/launch.json
1113

1214
# Packages
1315
*.egg

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Scenario (by name)",
6+
"type": "debugpy",
7+
"request": "launch",
8+
"cwd": "${workspaceFolder}",
9+
"module": "behave",
10+
"env": {
11+
"PYTHONPATH": "${workspaceFolder}"
12+
},
13+
"envFile": "${workspaceFolder}/.vscode/.env",
14+
"args": [
15+
"${file}",
16+
"-n",
17+
"${selectedText}"
18+
],
19+
"stopOnEntry": false,
20+
"justMyCode": false
21+
}
22+
]
23+
}

.vscode/settings.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"files.exclude": {
3+
"**/__pycache__": true,
4+
"**/*.pyc": true
5+
},
6+
"files.autoSave": "onFocusChange",
7+
"files.insertFinalNewline": true,
8+
"files.trimTrailingWhitespace": true,
9+
"editor.formatOnPaste": false,
10+
"editor.formatOnSave": true,
11+
"editor.rulers": [
12+
120
13+
],
14+
"[python]": {
15+
"editor.formatOnSave": true,
16+
"editor.defaultFormatter": "charliermarsh.ruff",
17+
"editor.codeActionsOnSave": {
18+
"source.organizeImports": "explicit"
19+
},
20+
},
21+
"python.envFile": "${workspaceFolder}/.vscode/.env",
22+
"python-envs.pythonProjects": [
23+
{
24+
"path": "",
25+
"envManager": "ms-python.python:venv",
26+
"packageManager": "ms-python.python:pip"
27+
}
28+
],
29+
"ruff.organizeImports": true,
30+
"cucumberautocomplete.steps": [
31+
"steps/**/*.py",
32+
],
33+
"cucumberautocomplete.customParameters": [
34+
{
35+
"parameter": "(u'",
36+
"value": "('"
37+
}
38+
],
39+
"cucumberautocomplete.syncfeatures": "features/**/*.feature",
40+
"cucumberautocomplete.gherkinDefinitionPart": "@(given|when|then|step)\\(",
41+
"cucumberautocomplete.strictGherkinCompletion": false,
42+
"cucumberautocomplete.strictGherkinValidation": false,
43+
"cucumberautocomplete.onTypeFormat": true,
44+
"gherkiner.consecutiveBlankLinesToOne": true,
45+
"gherkiner.padding.symbol": "space",
46+
"gherkiner.padding.table": 10,
47+
"gherkiner.formatOnSave": true,
48+
"gherkiner.paddings": [
49+
{
50+
"keyword": "Feature",
51+
"padding": 0
52+
},
53+
{
54+
"keyword": "Scenario Outline",
55+
"padding": 2
56+
},
57+
{
58+
"keyword": "Scenario",
59+
"padding": 2
60+
},
61+
{
62+
"keyword": "Given",
63+
"padding": 4
64+
},
65+
{
66+
"keyword": "When",
67+
"padding": 5
68+
},
69+
{
70+
"keyword": "Then",
71+
"padding": 5
72+
},
73+
{
74+
"keyword": "And",
75+
"padding": 6
76+
},
77+
{
78+
"keyword": "Actions",
79+
"padding": 2
80+
},
81+
{
82+
"keyword": "Examples",
83+
"padding": 4
84+
}
85+
]
86+
}

environment.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
1+
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
54
@@ -16,10 +15,14 @@
1615
limitations under the License.
1716
"""
1817

19-
from toolium.behave.environment import (before_all as toolium_before_all, before_feature as toolium_before_feature,
20-
before_scenario as toolium_before_scenario,
21-
after_scenario as toolium_after_scenario,
22-
after_feature as toolium_after_feature, after_all as toolium_after_all)
18+
from toolium.behave.environment import (
19+
after_all as toolium_after_all,
20+
after_feature as toolium_after_feature,
21+
after_scenario as toolium_after_scenario,
22+
before_all as toolium_before_all,
23+
before_feature as toolium_before_feature,
24+
before_scenario as toolium_before_scenario,
25+
)
2326

2427

2528
def before_all(context):

pageobjects/login.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
1+
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
54
@@ -17,9 +16,9 @@
1716
"""
1817

1918
from selenium.webdriver.common.by import By
20-
19+
from toolium.pageelements import Button, InputText
2120
from toolium.pageobjects.page_object import PageObject
22-
from toolium.pageelements import *
21+
2322
from pageobjects.message import MessagePageObject
2423
from pageobjects.secure_area import SecureAreaPageObject
2524

@@ -32,23 +31,23 @@ def init_page_elements(self):
3231
self.message = MessagePageObject()
3332

3433
def open(self):
35-
""" Open login url in browser
34+
"""Open login url in browser
3635
3736
:returns: this page object instance
3837
"""
3938
self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
4039
return self
4140

4241
def wait_until_loaded(self):
43-
""" Wait until login page is loaded
42+
"""Wait until login page is loaded
4443
4544
:returns: this page object instance
4645
"""
4746
self.username.wait_until_visible()
4847
return self
4948

5049
def login(self, user):
51-
""" Fill login form and submit it
50+
"""Fill login form and submit it
5251
5352
:param user: dict with username and password values
5453
:returns: secure area page object instance

pageobjects/message.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
1+
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
54
@@ -17,17 +16,16 @@
1716
"""
1817

1918
from selenium.webdriver.common.by import By
20-
19+
from toolium.pageelements import Text
2120
from toolium.pageobjects.page_object import PageObject
22-
from toolium.pageelements import *
2321

2422

2523
class MessagePageObject(PageObject):
2624
def init_page_elements(self):
2725
self.message = Text(By.ID, 'flash')
2826

2927
def get_message(self):
30-
""" Get first line of actual message
28+
"""Get first line of actual message
3129
3230
:returns: str with message
3331
"""

pageobjects/secure_area.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
1+
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
54
@@ -17,9 +16,9 @@
1716
"""
1817

1918
from selenium.webdriver.common.by import By
20-
19+
from toolium.pageelements import Button
2120
from toolium.pageobjects.page_object import PageObject
22-
from toolium.pageelements import *
21+
2322
from pageobjects.message import MessagePageObject
2423

2524

@@ -29,7 +28,7 @@ def init_page_elements(self):
2928
self.logout_button = Button(By.XPATH, "//div[@id='content']//i[contains(@class,'icon-signout')]")
3029

3130
def logout(self):
32-
""" Log out of secure area
31+
"""Log out of secure area
3332
3433
:returns: login page object instance
3534
"""

pyproject.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[project]
2+
name = "toolium-template"
3+
dynamic = ["dependencies"]
4+
authors = [
5+
{name = "Rubén González Alonso", email = "ruben.gonzalezalonso@telefonica.com"},
6+
]
7+
description = "Base project to start using toolium"
8+
readme = "README.rst"
9+
license = {text = "Apache 2.0"}
10+
requires-python = ">=3.10"
11+
12+
[tool.setuptools.dynamic]
13+
dependencies = {file = ["requirements.txt"]}
14+
15+
[tool.ruff]
16+
line-length = 120
17+
target-version = "py310"
18+
19+
[tool.ruff.lint]
20+
# Rules to enforce
21+
select = [
22+
"E", # pycodestyle errors
23+
"W", # pycodestyle warnings
24+
"F", # pyflakes
25+
"I", # isort
26+
"UP", # pyupgrade
27+
"N", # pep8-naming
28+
"A", # flake8-builtins
29+
"B", # flake8-bugbear
30+
"G", # flake8-logging-format
31+
"ARG", # flake8-unused-arguments
32+
"COM", # flake8-commas
33+
"C4", # flake8-comprehensions
34+
"PT", # flake8-pytest-style
35+
"T20", # flake8-print
36+
"RUF", # Ruff-specific rules
37+
]
38+
# Rules to ignore
39+
ignore = [
40+
"COM812", # flake8-missing-trailing-comas (conflict with ruff format)
41+
]
42+
43+
[tool.ruff.lint.isort]
44+
combine-as-imports = true
45+
split-on-trailing-comma = true
46+
known-first-party = ["acceptance"]
47+
section-order = [
48+
"future",
49+
"standard-library",
50+
"third-party",
51+
"first-party",
52+
"local-folder"
53+
]
54+
55+
[tool.ruff.format]
56+
quote-style = "single"
57+
indent-style = "space"
58+
skip-magic-trailing-comma = false
59+
line-ending = "auto"

steps/login.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
1+
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
54
@@ -16,28 +15,28 @@
1615
limitations under the License.
1716
"""
1817

19-
from behave import given, when, then
18+
from behave import given, then, when
2019

2120
from pageobjects.login import LoginPageObject
2221

2322

2423
@given('the home page is open')
25-
def step_impl(context):
24+
def home_page_is_open(context):
2625
context.current_page = LoginPageObject()
2726
context.current_page.open()
2827

2928

3029
@when('the user logs in with username "{username}" and password "{password}"')
31-
def step_impl(context, username, password):
30+
def user_logs_in(context, username, password):
3231
user = {'username': username, 'password': password}
3332
context.current_page = context.current_page.login(user)
3433

3534

3635
@when('the user logs out')
37-
def step_impl(context):
36+
def user_logs_out(context):
3837
context.current_page = context.current_page.logout()
3938

4039

4140
@then('the message "{message}" is shown')
42-
def step_impl(context, message):
41+
def message_is_shown(context, message):
4342
assert message in context.current_page.message.get_message()

0 commit comments

Comments
 (0)