Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Versions follow [Semantic Versioning](https://semver.org/): `<major>.<minor>.<patch>`.

## 0.22.1

* Add the `--hardpy-config-file` to the pytest plugin.
This feature enables tests to be run in a folder that is different
to the one containing the hardpy.toml file.
[[PR-259](https://github.com/everypinio/hardpy/pull/259)]

## 0.22.0

* Add the `get_hardpy_function` to retrieve the current configuration from the **hardpy.toml**.
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/hardpy_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ extra_arg_2 = 2
```python
import hardpy

config = get_hardpy_config()
config = hardpy.get_hardpy_config()
print(config.extra_args.["extra_arg_1"])
print(config.extra_args.["extra_arg_2"])
```
9 changes: 9 additions & 0 deletions docs/documentation/pytest_hardpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,15 @@ The default is *False*.
--sc-autosync
```

#### hardpy-config-file

The HardPy configuration file path ([hardpy.toml](./hardpy_config.md)).
The default is the tests path.

```bash
--hardpy-config-file path/to/file/
```

#### hardpy-start-arg

Dynamic arguments for test execution in key=value format. Can be specified multiple times.
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple_configs/hardpy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ tests_name = "Multiple configs"
current_test_config = ""

[database]
storage_type = "couchdb"
user = "dev"
password = "dev"
host = "localhost"
port = 5984

[frontend]
storage_type = "couchdb"
host = "localhost"
port = 8000
language = "en"
Expand Down
12 changes: 11 additions & 1 deletion hardpy/pytest_hardpy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def pytest_addoption(parser: Parser) -> None:
default=default_config.stand_cloud.autosync,
help="StandCloud auto syncronization",
)
parser.addoption(
"--hardpy-config-file",
action="store",
help="HardPy configuration file path",
)
parser.addoption(
"--hardpy-start-arg",
action="append",
Expand Down Expand Up @@ -151,7 +156,12 @@ def __init__(self) -> None:
def pytest_configure(self, config: Config) -> None:
"""Configure pytest."""
config_manager = ConfigManager()
hardpy_config = config_manager.read_config(Path(config.rootpath))

hardpy_config_path = config.getoption("--hardpy-config-file")
if hardpy_config_path:
hardpy_config = config_manager.read_config(Path(hardpy_config_path))
else:
hardpy_config = config_manager.read_config(Path(config.rootpath))

if not hardpy_config:
hardpy_config = HardpyConfig()
Expand Down
4 changes: 4 additions & 0 deletions hardpy/pytest_hardpy/pytest_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def start(
self._tests_name(),
"--sc-address",
self.config.stand_cloud.address,
"--hardpy-config-file",
str(self._config_manager.tests_path),
]

if selected_tests:
Expand Down Expand Up @@ -153,6 +155,8 @@ def collect(
self.config.database.url,
"--hardpy-tests-name",
self._tests_name(),
"--hardpy-config-file",
str(self._config_manager.tests_path),
"--hardpy-pt",
]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[project]
name = "hardpy"
version = "0.22.0"
version = "0.22.1"
description = "HardPy library for device testing"
license = "GPL-3.0-or-later"
authors = [{ name = "Everypin", email = "info@everypin.io" }]
Expand Down