Skip to content

Commit c9231ba

Browse files
authored
feat: add pyproject.toml file (#455)
* feat: add pyproject.toml file * fix unittest
1 parent 9e5d1d5 commit c9231ba

File tree

8 files changed

+171
-97
lines changed

8 files changed

+171
-97
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ publish
8585
.coverage
8686
tmp
8787
output
88+
docs/_build
8889
.eggs
8990
.tox
9091
.env

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ v3.7.1
66

77
*Release date: In development*
88

9+
- Add pyproject.toml file for packaging and publishing Toolium
910
- Add text analysis tool to get an overall match of a text against a list of expected characteristics
1011
using AI libraries that come with the `ai` extra dependency
1112

pyproject.toml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "toolium"
7+
dynamic = ["version", "dependencies", "optional-dependencies"]
8+
authors = [
9+
{name = "Rubén González Alonso", email = "[email protected]"},
10+
]
11+
description = "Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project"
12+
readme = "README.rst"
13+
license = {text = "Apache 2.0"}
14+
keywords = [
15+
"selenium",
16+
"appium",
17+
"webdriver",
18+
"web_automation",
19+
"mobile_automation",
20+
"page_object",
21+
"visual_testing",
22+
"ai",
23+
"bdd",
24+
"behave",
25+
"pytest"
26+
]
27+
classifiers = [
28+
"Development Status :: 5 - Production/Stable",
29+
"Intended Audience :: Developers",
30+
"Intended Audience :: Other Audience",
31+
"License :: OSI Approved :: Apache Software License",
32+
"Natural Language :: English",
33+
"Operating System :: OS Independent",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
39+
"Topic :: Software Development :: Libraries :: Python Modules",
40+
"Topic :: Software Development :: Quality Assurance",
41+
"Topic :: Software Development :: Testing",
42+
"Topic :: Software Development :: Testing :: Acceptance",
43+
"Topic :: Software Development :: Testing :: BDD",
44+
"Topic :: Text Processing :: Linguistic",
45+
]
46+
requires-python = ">=3.10"
47+
48+
[project.urls]
49+
Homepage = "https://github.com/telefonica/toolium"
50+
Repository = "https://github.com/telefonica/toolium"
51+
Documentation = "http://toolium.readthedocs.org/en/latest"
52+
Changelog = "http://toolium.readthedocs.org/en/latest/changelog.html"
53+
"Bug Tracker" = "https://github.com/telefonica/toolium/issues"
54+
55+
[tool.setuptools]
56+
packages = [
57+
"toolium",
58+
"toolium.pageobjects",
59+
"toolium.pageelements",
60+
"toolium.pageelements.playwright",
61+
"toolium.behave",
62+
"toolium.utils",
63+
"toolium.utils.ai_utils"
64+
]
65+
66+
[tool.setuptools.package-data]
67+
"toolium" = [
68+
"resources/VisualTestsTemplate.html",
69+
"resources/VisualTests.js",
70+
"resources/VisualTests.css"
71+
]
72+
73+
[tool.setuptools.dynamic]
74+
version = {file = "VERSION"}
75+
dependencies = {file = ["requirements.txt"]}
76+
optional-dependencies.playwright = {file = ["requirements_playwright.txt"]}
77+
optional-dependencies.ai = {file = ["requirements_ai.txt"]}
78+
optional-dependencies.dev = {file = ["requirements_dev.txt"]}
79+
80+
[tool.pytest.ini_options]
81+
testpaths = ["toolium/test"]
82+
python_files = ["test_*.py", "*_test.py"]
83+
python_classes = ["Test*"]
84+
python_functions = ["test_*"]
85+
addopts = "-v --tb=short"
86+
87+
[tool.coverage.run]
88+
source = ["toolium"]
89+
omit = [
90+
"*/test*",
91+
"*/tests/*",
92+
"*/venv/*",
93+
"*/.venv/*",
94+
]
95+
96+
[tool.coverage.report]
97+
exclude_lines = [
98+
"pragma: no cover",
99+
"def __repr__",
100+
"if self.debug:",
101+
"if settings.DEBUG",
102+
"raise AssertionError",
103+
"raise NotImplementedError",
104+
"if 0:",
105+
"if __name__ == .__main__.:",
106+
]
107+
108+
[tool.black]
109+
line-length = 120
110+
target-version = ['py310', 'py311', 'py312', 'py313']
111+
include = '\.pyi?$'
112+
extend-exclude = '''
113+
/(
114+
# directories
115+
\.eggs
116+
| \.git
117+
| \.hg
118+
| \.mypy_cache
119+
| \.tox
120+
| \.venv
121+
| build
122+
| dist
123+
)/
124+
'''
125+
126+
[tool.isort]
127+
profile = "black"
128+
line_length = 120
129+
multi_line_output = 3
130+
include_trailing_comma = true
131+
force_grid_wrap = 0
132+
use_parentheses = true
133+
ensure_newline_before_comments = true
134+
135+
[tool.ruff]
136+
line-length = 120
137+
target-version = "py310"
138+
select = [
139+
"E", # pycodestyle errors
140+
"W", # pycodestyle warnings
141+
"F", # pyflakes
142+
"I", # isort
143+
"B", # flake8-bugbear
144+
"C4", # flake8-comprehensions
145+
"UP", # pyupgrade
146+
]
147+
ignore = [
148+
"E501", # line too long, handled by black
149+
"B008", # do not perform function calls in argument defaults
150+
"C901", # too complex
151+
]
152+
153+
[tool.ruff.per-file-ignores]
154+
"__init__.py" = ["F401"]

requirements_ai.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spacy~=3.8.7
2+
sentence-transformers~=5.1
3+
transformers==4.56.2; python_version < '3.10'
4+
openai~=1.108

requirements_playwright.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
playwright~=1.43

setup.py

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -15,96 +15,13 @@
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
"""
18-
1918
from setuptools import setup
2019

20+
setup()
2121

22-
def read_file(filepath):
23-
with open(filepath) as f:
24-
return f.read()
25-
26-
27-
def get_long_description():
28-
"""Get README content and update rst urls
29-
30-
:returns: long description
31-
"""
32-
# Get readme content
33-
readme = read_file('README.rst')
34-
35-
# Change rst urls to ReadTheDocs html urls
36-
docs_url = 'http://toolium.readthedocs.org/en/latest'
37-
description = readme.replace('/CHANGELOG.rst', '{}/changelog.html'.format(docs_url))
38-
for doc in ['driver_configuration', 'page_objects', 'bdd_integration', 'visual_testing', 'tests_result_analysis']:
39-
description = description.replace('/docs/{}.rst'.format(doc), '{}/{}.html'.format(docs_url, doc))
40-
return description
41-
22+
"""
23+
Backward compatibility setup.py
4224
43-
setup(
44-
name='toolium',
45-
version=read_file('VERSION').strip(),
46-
packages=[
47-
'toolium',
48-
'toolium.pageobjects',
49-
'toolium.pageelements',
50-
'toolium.pageelements.playwright',
51-
'toolium.behave',
52-
'toolium.utils',
53-
'toolium.utils.ai_utils',
54-
],
55-
package_data={
56-
'': [
57-
'resources/VisualTestsTemplate.html',
58-
'resources/VisualTests.js',
59-
'resources/VisualTests.css',
60-
]
61-
},
62-
install_requires=read_file('requirements.txt').splitlines(),
63-
setup_requires=['pytest-runner'],
64-
tests_require=read_file('requirements_dev.txt').splitlines(),
65-
extras_require={
66-
"playwright": ["playwright~=1.43"],
67-
"ai": [
68-
"spacy~=3.8.7",
69-
"sentence-transformers~=5.1",
70-
"transformers==4.56.2; python_version < '3.10'",
71-
"openai~=1.108"
72-
]
73-
},
74-
test_suite='toolium.test',
75-
author='Rubén González Alonso, Telefónica I+D',
76-
author_email='[email protected]',
77-
url='https://github.com/telefonica/toolium',
78-
description='Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project',
79-
long_description_content_type='text/x-rst',
80-
long_description=get_long_description(),
81-
keywords=[
82-
'selenium',
83-
'appium',
84-
'webdriver',
85-
'web_automation',
86-
'mobile_automation',
87-
'page_object',
88-
'visual_testing',
89-
'ai',
90-
'bdd',
91-
'behave',
92-
'pytest'
93-
],
94-
classifiers=[
95-
'Development Status :: 5 - Production/Stable',
96-
'Intended Audience :: Developers',
97-
'Intended Audience :: Other Audience',
98-
'License :: OSI Approved :: Apache Software License',
99-
'Natural Language :: English',
100-
'Operating System :: OS Independent',
101-
'Programming Language :: Python :: 3.10',
102-
'Programming Language :: Python :: 3.11',
103-
'Programming Language :: Python :: 3.12',
104-
'Programming Language :: Python :: 3.13',
105-
'Topic :: Software Development :: Libraries :: Python Modules',
106-
'Topic :: Software Development :: Quality Assurance',
107-
'Topic :: Software Development :: Testing',
108-
],
109-
license='Apache 2.0',
110-
)
25+
All package configuration has been moved to pyproject.toml
26+
This file exists only for backward compatibility with older tools.
27+
"""

toolium/test/utils/ai_utils/test_text_analysis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def configure_default_openai_model():
4646
)
4747

4848

49-
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
50-
reason="AZURE_OPENAI_API_KEY environment variable not set")
49+
@pytest.mark.skipif(not os.getenv("AZURE_OPENAI_API_KEY"), reason="AZURE_OPENAI_API_KEY environment variable not set")
5150
@pytest.mark.parametrize('input_text, features_list, expected_low, expected_high', get_analysis_examples)
5251
def test_get_text_analysis(input_text, features_list, expected_low, expected_high):
5352
similarity = json.loads(get_text_criteria_analysis(input_text, features_list, azure=True))

toolium/test/utils/ai_utils/test_text_similarity.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def test_get_text_similarity_with_sentence_transformers(input_text, expected_tex
6969
)
7070

7171

72-
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
73-
reason="AZURE_OPENAI_API_KEY environment variable not set")
72+
@pytest.mark.skipif(not os.getenv("AZURE_OPENAI_API_KEY"), reason="AZURE_OPENAI_API_KEY environment variable not set")
7473
@pytest.mark.parametrize('input_text, expected_text, expected_low, expected_high', get_openai_similarity_examples)
7574
def test_get_text_similarity_with_azure_openai(input_text, expected_text, expected_low, expected_high):
7675
configure_default_openai_model()
@@ -96,8 +95,7 @@ def test_assert_text_similarity_with_sentence_transformers_passed(input_text, ex
9695
assert_text_similarity(input_text, expected_text, threshold=threshold, similarity_method='sentence_transformers')
9796

9897

99-
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
100-
reason="AZURE_OPENAI_API_KEY environment variable not set")
98+
@pytest.mark.skipif(not os.getenv("AZURE_OPENAI_API_KEY"), reason="AZURE_OPENAI_API_KEY environment variable not set")
10199
@pytest.mark.parametrize('input_text, expected_text, threshold', assert_similarity_passed_examples)
102100
def test_assert_text_similarity_with_openai_passed(input_text, expected_text, threshold):
103101
configure_default_openai_model()
@@ -131,8 +129,7 @@ def test_assert_text_similarity_with_sentence_transformers_failed(input_text, ex
131129
)
132130

133131

134-
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
135-
reason="AZURE_OPENAI_API_KEY environment variable not set")
132+
@pytest.mark.skipif(not os.getenv("AZURE_OPENAI_API_KEY"), reason="AZURE_OPENAI_API_KEY environment variable not set")
136133
@pytest.mark.parametrize('input_text, expected_text, threshold', assert_openai_similarity_failed_examples)
137134
def test_assert_text_similarity_with_openai_failed(input_text, expected_text, threshold):
138135
configure_default_openai_model()

0 commit comments

Comments
 (0)