Commit Graph
45 Commits
Author SHA1 Message Date
9e8df72c0d Improve is docker env checks (#132404)
Co-authored-by: Franck Nijhof <[email protected]>
Co-authored-by: Sander Hoentjen <[email protected]>
Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Robert Resch <[email protected]>
2025-01-02 17:21:49 +01:00
Steven B.andGitHub 59e5eb9a1c Always use uv from virtual environment at runtime (#128371) 2024-10-16 19:42:25 +02:00
5d2f8319b1 Update string formatting to use f-string on tests (#125986)
* Update string formatting to use f-string on tests

* Update test_package.py

Co-authored-by: epenet <[email protected]>

* Update statement given feedback

---------

Co-authored-by: epenet <[email protected]>
2024-09-19 10:32:38 +02:00
Robert ReschandGitHub d9812f0d48 Fix uv installing in user site packages (#125808) 2024-09-15 14:53:45 +02:00
Robert ReschandGitHub 7555f209b6 Use uv at runtime too (#125110) 2024-09-11 09:43:26 +02:00
SidandGitHub d5f883fbf0 Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Marc MuellerandGitHub a6b842f818 Add empty line after module docstring (2) [other] (#112738) 2024-03-08 19:16:38 +01:00
J. Nick KostonandGitHub 8afcd53af6 Restore support for packages being installed from urls with fragments (#109267) 2024-02-01 08:56:57 +01:00
J. Nick KostonandGitHub 75d591593d Remove calls to distribution and legacy zip support from package util (#107427) 2024-01-07 07:39:48 -10:00
Franck NijhofandGitHub 664e490cfa Update base image to 2023.10.0 (#102126) 2023-10-18 19:11:41 +02:00
Marc MuellerandGitHub 1daac46635 Replace deprecated pkg_resources with importlib.metadata (#97628) 2023-08-03 09:14:00 +02:00
epenetandGitHub 5f25b71df7 Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
J. Nick KostonandGitHub 03eea7bd3f Avoid subprocess memory copy when c library supports posix_spawn (#87958)
* use posix spawn on alpine

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy all the memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
https://github.com/python/cpython/blob/1b736838e6ae1b4ef42cdd27c2708face908f92c/Lib/subprocess.py#L745

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided and subprocess creation does not
get discernibly slow the larger the Home Assistant
python process grows.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
https://github.com/python/cpython/blob/1b736838e6ae1b4ef42cdd27c2708face908f92c/Lib/subprocess.py#L745

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* missed some

* adjust more tests

* coverage
2023-02-13 09:02:51 -05:00
epenetandGitHub 4142f0d15d Add return type to tests without arguments (#87613)
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
henryptungandGitHub 7d27dad190 Remove pip --prefix workaround (#74922)
Remove --prefix workaround

See discussion in https://github.com/home-assistant/core/issues/74405.

This workaround is no longer needed on pip >= 21.0 and actively causes problems for pip >= 21.3.
2022-07-11 11:33:28 +02:00
Erik MontnemeryandGitHub fa952364cc Remove test_check_package_version_does_not_match (#59785) 2021-11-16 07:54:08 -08:00
Marc MuellerandGitHub f1d48ddfe3 Update pylint to 2.8.0 (#49637) 2021-04-24 14:39:24 -10:00
J. Nick KostonandGitHub 9a686d148e Ensure startup can proceed when there is package metadata cruft (#47706)
If a package fails to install or partially installed importlib
version can return None. We now try pkg_resources first, then
try importlib, and handle the case where version unexpectedly
returns None
2021-03-10 21:12:02 -10:00
Franck NijhofandGitHub 65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Paulus SchoutsenandGitHub 51a63c1fc4 Drop last bits of asyncio.coroutine (#39280) 2020-08-26 16:57:52 +02:00
Paulus SchoutsenandGitHub ec47216388 Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
Paulus SchoutsenandGitHub e7f8d6bbf7 Fix more tests on Python 3.8 (#34703) 2020-04-25 15:52:50 -07:00
Bas NijholtandFranck Nijhof f60125b5c9 Sort imports according to PEP8 for 'tests' (#29791) 2019-12-09 16:52:24 +01:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Pascal VizeliandPaulus Schoutsen c9453bab19 Prefere binary with wheels (#24669) 2019-06-21 08:47:56 -07:00
Pascal VizeliandPaulus Schoutsen d9852bc75d Support Hass.io wheels / docker env (#24175)
* Support Hass.io wheels / docker env

* address comments

* fix lint
2019-05-29 15:30:09 -07:00
Paulus SchoutsenandGitHub 179fb0f3b5 Use importlib metadata to check installed packages (#24114)
* Use importlib metadata

* Fix script

* Remove unused import

* Update requirements"
2019-05-26 11:58:42 -07:00
Paulus SchoutsenandGitHub 09dc4d663d Improve package loadable (#16237)
* Add caching to package loadable

* Fix tests

* Improve package loadable

* Lint

* Typing
2018-08-28 12:52:18 +02:00
Paulus SchoutsenandGitHub a14980716d Package loadable: compare case insensitive (#16234) 2018-08-28 10:53:12 +02:00
Paulus SchoutsenandPascal Vizeli 2e6cb2235c Check correctly if package is loadable (#16121) 2018-08-22 12:17:14 +02:00
Paulus SchoutsenandGitHub 0b114f0755 Do not mount deps folder when running in virtual env (#14993)
* Do not mount deps folder when inside virtual env

* Add tests

* Fix package test
2018-06-16 10:48:41 -04:00
Paulus SchoutsenandGitHub 38af04c6ce Reinstate our old virtual env check in favor of pip (#12932) 2018-03-05 15:51:37 -08:00
Martin HjelmareandPaulus Schoutsen 543e8bb62e Fix check for running inside venv (#8481)
* Import and use the function from pip instead of defining it
  ourselves.
* Fix tests.
2017-07-15 07:25:02 -07:00
Martin HjelmareandPaulus Schoutsen ba019c799a Make deps directory persistent over upgrades (#7801)
* Use pip install --user if venv not active

* Set PYTHONUSERBASE to deps directory, when installing with --user
  option.
* Reset --prefix option to workaround incompatability when installing
  with --user option. This requires pip version 8.0.0 or greater.
* Require pip version 8.0.3.
* Do not delete deps directory on home assistant upgrade.
* Fix local lib mount and check package exist.

* Update and add tests

* Fix upgrade from before version 0.46

* Extract function to get user site

* Add function(s) to package util to get user site.
* Use async subprocess for one of the functions to get user site.
* Add function to package util to check if virtual environment is
  active.
* Add and update tests.

* Update version for last removal of deps dir

* Address comments

* Rewrite package util tests with pytest

* Rewrite all existing unittest class based tests for package util as
  test functions, and capitalize pytest fixtures.
* Add test for installing with target inside venv.
2017-07-13 19:26:21 -07:00
Pierre StåhlandPascal Vizeli f5dd25c87f Capture and log pip install error output (#7200)
Add an optional extended description…
2017-04-21 14:15:05 +02:00
Fabian AffolterandGitHub 3aa1b6a3f8 Fix PEP257 issues (#3962) 2016-10-20 19:10:12 +02:00
Rob CapelliniandPaulus Schoutsen 272539105f Replacing tempfile with mock_open in tests (#3753)
- test_bootstrap.py
- test_config.py
- components/test_init.py
- components/test_panel_custom.py
- components/test_api.py
- components/notify/test_file.py
- components/notify/test_demo.py
- components/camera/test_local_file.py
- helpers/test_config_validation.py
- util/test_package.py
- util/test_yaml.py

No changes needed in:
- components/cover/test_command_line.py
- components/switch/test_command_line.py
- components/rollershutter/test_command_line.py
- components/test_shell_command.py
- components/notify/test_command_line.py

Misc changes in:
- components/mqtt/test_server.py

Also, removed some unused mock parameters in tests/components/mqtt/test_server.py.
2016-10-17 20:16:36 -07:00
Johann KellermanandPaulus Schoutsen aadf6a7750 Handle requirements for scripts (#2765) 2016-08-09 23:54:34 -07:00
Paulus SchoutsenandGitHub 6714392e9c Move elevation to core config and clean up HTTP mocking in tests (#2378)
* Stick version numbers

* Move elevation to core config

* Migrate forecast test to requests-mock

* Migrate YR tests to requests-mock

* Add requests_mock to requirements_test.txt

* Move conf code from bootstrap to config

* More config fixes

* Fix some more issues

* Add test for set config and failing auto detect
2016-06-27 09:02:45 -07:00
Jan HarkesandPaulus Schoutsen 241735c924 Change local library path from {config_dir}/lib to {config_dir}/deps. (#1799)
Just on the off chance that someone who happens to run as root and also
doesn't correctly parse "just remove config /lib and restart".
2016-04-11 20:07:50 -07:00
Fabian Affolter 9838697d2b Fix PEP257 issues 2016-03-09 10:25:50 +01:00
Fabian Affolter 00afaac54c Update for file header, docstrings, and PEP8/PEP257 2016-02-13 14:19:11 +01:00
Ryan Kraus 56ac4281c7 Better tear down of util/package tests
Explicitly removed temp directory at the end of util/package unit tests.
2016-01-30 14:39:17 -05:00
Ryan Kraus 4a8f55e630 Revised package util tests
The package util tests were revised to pull the external library
pyhelloworld3 from an internal source rather than external. This speeds
up tests, makes tests more reliable, and removes dependency on internet
connection.
2016-01-30 14:08:32 -05:00
Ryan Kraus 0631f5c59d Added tests for package utilities 2016-01-30 06:44:22 -05:00