Skip to content

Commit ae16741

Browse files
authored
feat: configure ruff and format files (#46)
* feat: configure ruff and format files * use default .env in root folder
1 parent 09d0f85 commit ae16741

71 files changed

Lines changed: 574 additions & 367 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ['3.13']
11+
fail-fast: false
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt
23+
pip install -r requirements_dev.txt
24+
- name: Lint and format check with ruff
25+
run: |
26+
ruff check .
27+
ruff format --check .

.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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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}/.env",
14+
"args": [
15+
"${file}",
16+
"-n",
17+
"${selectedText}"
18+
],
19+
"stopOnEntry": false,
20+
"justMyCode": false
21+
},
22+
{
23+
"name": "Pytest: current file",
24+
"type": "debugpy",
25+
"request": "launch",
26+
"cwd": "${workspaceFolder}/web_pytest",
27+
"module": "pytest",
28+
"args": [
29+
"${file}"
30+
],
31+
"justMyCode": false
32+
},
33+
{
34+
"name": "Pytest BDD: current file",
35+
"type": "debugpy",
36+
"request": "launch",
37+
"cwd": "${workspaceFolder}/web_pytest_bdd",
38+
"module": "pytest",
39+
"args": [
40+
"${file}"
41+
],
42+
"justMyCode": false
43+
},
44+
{
45+
"name": "Playwright: current file",
46+
"type": "debugpy",
47+
"request": "launch",
48+
"cwd": "${workspaceFolder}/web_pytest",
49+
"module": "pytest",
50+
"args": [
51+
"${file}",
52+
"--headed",
53+
"--browser",
54+
"firefox"
55+
],
56+
"justMyCode": false
57+
},
58+
{
59+
"name": "Pynose2: current file",
60+
"type": "debugpy",
61+
"request": "launch",
62+
"cwd": "${workspaceFolder}/web_nose2",
63+
"module": "pytest",
64+
"args": [
65+
"${file}"
66+
],
67+
"justMyCode": false
68+
}
69+
]
70+
}

.vscode/settings.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
"ruff.organizeImports": true,
22+
"cucumberautocomplete.steps": [
23+
"**/steps/**/*.py",
24+
],
25+
"cucumberautocomplete.customParameters": [
26+
{
27+
"parameter": "(u'",
28+
"value": "('"
29+
}
30+
],
31+
"cucumberautocomplete.syncfeatures": "**/features/**/*.feature",
32+
"cucumberautocomplete.gherkinDefinitionPart": "@(given|when|then|step)\\(",
33+
"cucumberautocomplete.strictGherkinCompletion": false,
34+
"cucumberautocomplete.strictGherkinValidation": false,
35+
"cucumberautocomplete.onTypeFormat": true,
36+
"gherkiner.consecutiveBlankLinesToOne": true,
37+
"gherkiner.padding.symbol": "space",
38+
"gherkiner.padding.table": 10,
39+
"gherkiner.formatOnSave": true,
40+
"gherkiner.paddings": [
41+
{
42+
"keyword": "Feature",
43+
"padding": 0
44+
},
45+
{
46+
"keyword": "Scenario Outline",
47+
"padding": 2
48+
},
49+
{
50+
"keyword": "Scenario",
51+
"padding": 2
52+
},
53+
{
54+
"keyword": "Given",
55+
"padding": 4
56+
},
57+
{
58+
"keyword": "When",
59+
"padding": 5
60+
},
61+
{
62+
"keyword": "Then",
63+
"padding": 5
64+
},
65+
{
66+
"keyword": "And",
67+
"padding": 6
68+
},
69+
{
70+
"keyword": "Actions",
71+
"padding": 2
72+
},
73+
{
74+
"keyword": "Examples",
75+
"padding": 4
76+
}
77+
]
78+
}

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ Contributing
169169
If you want to collaborate in Toolium-examples development, feel free of `forking it <https://github.com/Telefonica/toolium-examples>`_
170170
and asking for a pull request.
171171

172+
Before submitting your changes, make sure the code follows the project's style by running Ruff:
173+
174+
.. code:: console
175+
176+
$ pip install ruff
177+
$ ruff check --fix . # Fix linting issues
178+
$ ruff format . # Format code
179+
172180
Finally, before accepting your contribution, we need you to sign our
173181
`Contributor License Agreement <https://raw.githubusercontent.com/telefonicaid/Licensing/master/ContributionPolicy.txt>`_
174182
and send it to ruben.gonzalezalonso@telefonica.com.

android_behave/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):

android_behave/pageobjects/menu.py

Lines changed: 5 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,13 +16,14 @@
1716
"""
1817

1918
from appium.webdriver.common.appiumby import AppiumBy
20-
2119
from toolium.pageobjects.page_object import PageObject
2220

2321

2422
class MenuPageObject(PageObject):
25-
option_locator = 'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
26-
'.scrollIntoView(new UiSelector().text("{}").instance(0));'
23+
option_locator = (
24+
'new UiScrollable(new UiSelector().scrollable(true).instance(0))'
25+
'.scrollIntoView(new UiSelector().text("{}").instance(0));'
26+
)
2727

2828
def open_option(self, option):
2929
"""Search a menu option and click on it

android_behave/pageobjects/tabs.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,9 +16,8 @@
1716
"""
1817

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

2422

2523
class TabsPageObject(PageObject):
@@ -30,4 +28,4 @@ class TabsPageObject(PageObject):
3028
content1 = Text(By.ID, 'io.appium.android.apis:id/view1')
3129
content2 = Text(By.ID, 'io.appium.android.apis:id/view2')
3230
content3 = Text(By.ID, 'io.appium.android.apis:id/view3')
33-
container = PageElement(By.ID, 'android:id/content')
31+
container = PageElement(By.ID, 'android:id/content')

android_behave/steps/tabs.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 android_behave.pageobjects.menu import MenuPageObject
2221
from android_behave.pageobjects.tabs import TabsPageObject
2322

2423

2524
@given('the menu is open')
26-
def step_impl(context):
25+
def menu_is_open(context):
2726
context.current_page = MenuPageObject()
2827

2928

3029
@when('the user goes to the tabs-by-id screen')
31-
def step_impl(context):
30+
def go_to_tabs_by_id_screen(context):
3231
context.current_page.open_option('Views').open_option('Tabs').open_option('1. Content By Id')
3332
context.current_page = TabsPageObject()
3433

3534

3635
@when('the user opens the second tab')
37-
def step_impl(context):
36+
def open_second_tab(context):
3837
context.current_page.tab2.click()
3938

4039

4140
@then('the second tab contains "{message}"')
42-
def step_impl(context, message):
41+
def second_tab_contains_message(context, message):
4342
assert message in context.current_page.content2.text

android_nose2/pageobjects/drag_and_drop.py

Lines changed: 4 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,11 +15,10 @@
1615
limitations under the License.
1716
"""
1817

18+
from selenium.webdriver import ActionChains
1919
from selenium.webdriver.common.by import By
20-
from appium.webdriver.common.touch_action import TouchAction
21-
20+
from toolium.pageelements import PageElement, Text
2221
from toolium.pageobjects.page_object import PageObject
23-
from toolium.pageelements import *
2422

2523

2624
class DragAndDropPageObject(PageObject):
@@ -30,4 +28,4 @@ class DragAndDropPageObject(PageObject):
3028
result = Text(By.ID, 'io.appium.android.apis:id/drag_result_text')
3129

3230
def drag_and_drop(self):
33-
TouchAction(self.driver).long_press(self.dot3.web_element).move_to(self.dot2.web_element).release().perform()
31+
ActionChains(self.driver).drag_and_drop(self.dot3.web_element, self.dot2.web_element).perform()

0 commit comments

Comments
 (0)