xvfbwrapper 0.2.23__tar.gz → 0.2.25__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xvfbwrapper
3
- Version: 0.2.23
3
+ Version: 0.2.25
4
4
  Summary: Manage headless displays with Xvfb (X virtual framebuffer)
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -44,6 +44,11 @@ Dynamic: license-file
44
44
  - Releases: [PyPI][pypi-home]
45
45
  - License: [MIT][mit-license]
46
46
 
47
+ The package provides the `xvfvwrapper.Xvfb` class that is used to interact with
48
+ an Xvfb server.
49
+
50
+ See the [module API documentation][api-docs] for more information.
51
+
47
52
  ----
48
53
 
49
54
  ## Status
@@ -253,14 +258,11 @@ import unittest
253
258
  from selenium import webdriver
254
259
  from xvfbwrapper import Xvfb
255
260
 
256
- # force X11 in case we are running on a Wayland system
257
- os.environ["XDG_SESSION_TYPE"] = "x11"
258
-
259
261
 
260
262
  class TestPage(unittest.TestCase):
261
263
 
262
264
  def setUp(self):
263
- xvfb = Xvfb()
265
+ xvfb = Xvfb(set_xdg_session_type=True)
264
266
  xvfb.start()
265
267
  self.driver = webdriver.Chrome()
266
268
  self.addCleanup(xvfb.stop)
@@ -282,26 +284,11 @@ if __name__ == "__main__":
282
284
 
283
285
  ----
284
286
 
285
- ## xvfbwrapper Issues
286
-
287
- To report a bug or request a new feature, please open an issue on [GitHub][github-issues].
288
-
289
- ----
290
-
291
- ## xvfbwrapper Development
287
+ ## Development
292
288
 
293
- 1. Fork the project repo on [GitHub][github-repo]
289
+ - Git: [github.com/cgoldberg/xvfbwrapper.git][github-repo]
294
290
 
295
- 2. Clone the repo:
296
-
297
- ```
298
- git clone https://github.com/<USERNAME>/xvfbwrapper.git
299
- cd xvfbwrapper
300
- ```
301
-
302
- 3. Make changes and run the tests:
303
-
304
- Create a virtual env and install required testing packages:
291
+ - Create a virtual env and install required testing packages:
305
292
 
306
293
  ```
307
294
  python -m venv venv
@@ -309,27 +296,21 @@ To report a bug or request a new feature, please open an issue on [GitHub][githu
309
296
  pip install --editable --group dev --group test .
310
297
  ```
311
298
 
312
- Run all tests in the default Python environment:
299
+ - Run all tests in the default Python environment:
313
300
 
314
301
  ```
315
302
  pytest
316
303
  ```
317
304
 
318
- Run all tests, linting, and type checking across all supported/installed
319
- Python environments:
305
+ - Run all tests, linting, and type checking across all supported/installed
306
+ Python environments:
320
307
 
321
308
  ```
322
309
  tox
323
310
  ```
324
311
 
325
- 4. Commit and push your changes
326
-
327
- 5. Submit a [Pull Request][github-prs]
328
-
329
-
330
312
  [github-profile]: https://github.com/cgoldberg
331
313
  [github-repo]: https://github.com/cgoldberg/xvfbwrapper
332
- [github-issues]: https://github.com/cgoldberg/xvfbwrapper/issues
333
- [github-prs]: https://github.com/cgoldberg/xvfbwrapper/pulls
334
314
  [pypi-home]: https://pypi.org/project/xvfbwrapper
335
315
  [mit-license]: https://raw.githubusercontent.com/cgoldberg/xvfbwrapper/refs/heads/master/LICENSE
316
+ [api-docs]: https://coreygoldberg.com/xvfbwrapper
@@ -13,6 +13,11 @@
13
13
  - Releases: [PyPI][pypi-home]
14
14
  - License: [MIT][mit-license]
15
15
 
16
+ The package provides the `xvfvwrapper.Xvfb` class that is used to interact with
17
+ an Xvfb server.
18
+
19
+ See the [module API documentation][api-docs] for more information.
20
+
16
21
  ----
17
22
 
18
23
  ## Status
@@ -222,14 +227,11 @@ import unittest
222
227
  from selenium import webdriver
223
228
  from xvfbwrapper import Xvfb
224
229
 
225
- # force X11 in case we are running on a Wayland system
226
- os.environ["XDG_SESSION_TYPE"] = "x11"
227
-
228
230
 
229
231
  class TestPage(unittest.TestCase):
230
232
 
231
233
  def setUp(self):
232
- xvfb = Xvfb()
234
+ xvfb = Xvfb(set_xdg_session_type=True)
233
235
  xvfb.start()
234
236
  self.driver = webdriver.Chrome()
235
237
  self.addCleanup(xvfb.stop)
@@ -251,26 +253,11 @@ if __name__ == "__main__":
251
253
 
252
254
  ----
253
255
 
254
- ## xvfbwrapper Issues
255
-
256
- To report a bug or request a new feature, please open an issue on [GitHub][github-issues].
257
-
258
- ----
259
-
260
- ## xvfbwrapper Development
256
+ ## Development
261
257
 
262
- 1. Fork the project repo on [GitHub][github-repo]
258
+ - Git: [github.com/cgoldberg/xvfbwrapper.git][github-repo]
263
259
 
264
- 2. Clone the repo:
265
-
266
- ```
267
- git clone https://github.com/<USERNAME>/xvfbwrapper.git
268
- cd xvfbwrapper
269
- ```
270
-
271
- 3. Make changes and run the tests:
272
-
273
- Create a virtual env and install required testing packages:
260
+ - Create a virtual env and install required testing packages:
274
261
 
275
262
  ```
276
263
  python -m venv venv
@@ -278,27 +265,21 @@ To report a bug or request a new feature, please open an issue on [GitHub][githu
278
265
  pip install --editable --group dev --group test .
279
266
  ```
280
267
 
281
- Run all tests in the default Python environment:
268
+ - Run all tests in the default Python environment:
282
269
 
283
270
  ```
284
271
  pytest
285
272
  ```
286
273
 
287
- Run all tests, linting, and type checking across all supported/installed
288
- Python environments:
274
+ - Run all tests, linting, and type checking across all supported/installed
275
+ Python environments:
289
276
 
290
277
  ```
291
278
  tox
292
279
  ```
293
280
 
294
- 4. Commit and push your changes
295
-
296
- 5. Submit a [Pull Request][github-prs]
297
-
298
-
299
281
  [github-profile]: https://github.com/cgoldberg
300
282
  [github-repo]: https://github.com/cgoldberg/xvfbwrapper
301
- [github-issues]: https://github.com/cgoldberg/xvfbwrapper/issues
302
- [github-prs]: https://github.com/cgoldberg/xvfbwrapper/pulls
303
283
  [pypi-home]: https://pypi.org/project/xvfbwrapper
304
284
  [mit-license]: https://raw.githubusercontent.com/cgoldberg/xvfbwrapper/refs/heads/master/LICENSE
285
+ [api-docs]: https://coreygoldberg.com/xvfbwrapper
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xvfbwrapper"
7
- version = "0.2.23"
7
+ version = "0.2.25"
8
8
  description = "Manage headless displays with Xvfb (X virtual framebuffer)"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -41,17 +41,15 @@ dev = [
41
41
  "tox",
42
42
  ]
43
43
  lint = [
44
- "black",
45
- "refurb",
46
44
  "ruff",
47
45
  ]
48
46
  test = [
49
47
  "psutil",
50
48
  "pytest",
51
- "pytest-cov",
52
49
  ]
53
50
  type = [
54
51
  "mypy",
52
+ "types-psutil",
55
53
  ]
56
54
  validate = [
57
55
  "packaging",
@@ -62,14 +60,8 @@ validate = [
62
60
  [tool.setuptools]
63
61
  py-modules = ["xvfbwrapper"]
64
62
 
65
- [tool.pytest.ini_options]
66
- addopts = "-vv" # extra verbose
67
-
68
- [tool.black]
69
- line-length = 88
70
- target-version = [
71
- "py310", "py311", "py312", "py313", "py314"
72
- ]
63
+ [tool.pytest]
64
+ addopts = ["-v"]
73
65
 
74
66
  [tool.ruff]
75
67
  line-length = 88
@@ -77,18 +69,14 @@ respect-gitignore = true
77
69
  target-version = "py310"
78
70
 
79
71
  [tool.ruff.lint]
80
- fixable = ["ALL"]
81
- select = [
82
- "D", "E", "F", "I", "N", "FURB", "RUF", "TID", "UP", "W"
83
- ]
72
+ select = ["ALL"]
84
73
  extend-ignore = [
85
- "D100", "D101", "D102", "D103", "D105", "D107", "D203", "D213"
74
+ "ANN", "COM812", "D", "EM101", "EM102", "FBT", "PERF203",
75
+ "PLR", "PT", "PYI034", "SLF001", "S101", "S108", "S311",
76
+ "S603", "TRY003", "TRY400"
86
77
  ]
78
+ fixable = ["ALL"]
87
79
 
88
80
  [tool.ruff.format]
89
81
  docstring-code-format = true
90
82
  docstring-code-line-length = 88
91
-
92
- [tool.refurb]
93
- python_version = "3.10"
94
- enable_all = true
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env python3
2
-
2
+ # Copyright (c) 2012-2026 Corey Goldberg
3
+ # SPDX-License-Identifier: MIT
3
4
 
4
5
  """Tests for xvfbwrapper."""
5
6
 
@@ -7,6 +8,7 @@ import os
7
8
  import sys
8
9
  import tempfile
9
10
  import unittest
11
+ from contextlib import suppress
10
12
  from unittest.mock import patch
11
13
 
12
14
  import psutil
@@ -52,10 +54,8 @@ class XvfbCleanTestCase(unittest.TestCase):
52
54
  continue
53
55
  _, alive = psutil.wait_procs(procs, timeout=3)
54
56
  for proc in alive:
55
- try:
57
+ with suppress(psutil.NoSuchProcess, psutil.AccessDenied):
56
58
  proc.kill()
57
- except (psutil.NoSuchProcess, psutil.AccessDenied):
58
- pass
59
59
 
60
60
  # ---------- Class-level ----------
61
61
 
@@ -375,11 +375,13 @@ class TestXvfb(XvfbCleanTestCase):
375
375
  "bar",
376
376
  ]
377
377
  # Force the display socket to never appear
378
- with patch.object(xvfb, "_local_display_exists", return_value=False):
379
- with self.assertRaisesRegex(
378
+ with (
379
+ patch.object(xvfb, "_local_display_exists", return_value=False),
380
+ self.assertRaisesRegex(
380
381
  RuntimeError, f"Xvfb display did not open: {expected_cmd_args}"
381
- ):
382
- xvfb.start()
382
+ ),
383
+ ):
384
+ xvfb.start()
383
385
  # After failure, calling stop() again must not raise an exception
384
386
  xvfb.stop()
385
387
  # We never injected DISPLAY into our custom env
@@ -6,8 +6,6 @@
6
6
  # "tox -e <env>" (i.e.: "tox -e py314" or "tox -e lint")
7
7
  #
8
8
  # This tox configuration will skip any Python interpreters that can't be found.
9
- # To manage multiple Python interpreters for covering all versions, you can use
10
- # pyenv: https://github.com/pyenv/pyenv
11
9
 
12
10
 
13
11
  [tox]
@@ -16,6 +14,9 @@ envlist =
16
14
  lint
17
15
  type
18
16
  py310
17
+ py311
18
+ py312
19
+ py313
19
20
  py314
20
21
  pypy3
21
22
  skip_missing_interpreters = true
@@ -27,7 +28,7 @@ platform = linux|darwin|.*bsd.*
27
28
  dependency_groups =
28
29
  test
29
30
  commands =
30
- pytest --cov=xvfbwrapper {posargs:.}
31
+ pytest {posargs:.}
31
32
 
32
33
 
33
34
  [testenv:validate]
@@ -47,13 +48,8 @@ dependency_groups =
47
48
  lint
48
49
  skip_install = true
49
50
  commands =
50
- # crazy workaround so black doesn't print red messages to console on success
51
- {envpython} -c "import subprocess as s; import sys; "\
52
- "r = s.run(['black', '.'], capture_output=True, text=True, encoding='utf-8'); "\
53
- "sys.stdout.write(r.stderr) if not r.returncode else sys.stderr.write(r.stderr)"
54
51
  ruff check --fix --show-fixes --exit-non-zero-on-fix .
55
52
  ruff format --exit-non-zero-on-format .
56
- refurb xvfbwrapper.py test_xvfb.py
57
53
 
58
54
 
59
55
  [testenv:type]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xvfbwrapper
3
- Version: 0.2.23
3
+ Version: 0.2.25
4
4
  Summary: Manage headless displays with Xvfb (X virtual framebuffer)
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -44,6 +44,11 @@ Dynamic: license-file
44
44
  - Releases: [PyPI][pypi-home]
45
45
  - License: [MIT][mit-license]
46
46
 
47
+ The package provides the `xvfvwrapper.Xvfb` class that is used to interact with
48
+ an Xvfb server.
49
+
50
+ See the [module API documentation][api-docs] for more information.
51
+
47
52
  ----
48
53
 
49
54
  ## Status
@@ -253,14 +258,11 @@ import unittest
253
258
  from selenium import webdriver
254
259
  from xvfbwrapper import Xvfb
255
260
 
256
- # force X11 in case we are running on a Wayland system
257
- os.environ["XDG_SESSION_TYPE"] = "x11"
258
-
259
261
 
260
262
  class TestPage(unittest.TestCase):
261
263
 
262
264
  def setUp(self):
263
- xvfb = Xvfb()
265
+ xvfb = Xvfb(set_xdg_session_type=True)
264
266
  xvfb.start()
265
267
  self.driver = webdriver.Chrome()
266
268
  self.addCleanup(xvfb.stop)
@@ -282,26 +284,11 @@ if __name__ == "__main__":
282
284
 
283
285
  ----
284
286
 
285
- ## xvfbwrapper Issues
286
-
287
- To report a bug or request a new feature, please open an issue on [GitHub][github-issues].
288
-
289
- ----
290
-
291
- ## xvfbwrapper Development
287
+ ## Development
292
288
 
293
- 1. Fork the project repo on [GitHub][github-repo]
289
+ - Git: [github.com/cgoldberg/xvfbwrapper.git][github-repo]
294
290
 
295
- 2. Clone the repo:
296
-
297
- ```
298
- git clone https://github.com/<USERNAME>/xvfbwrapper.git
299
- cd xvfbwrapper
300
- ```
301
-
302
- 3. Make changes and run the tests:
303
-
304
- Create a virtual env and install required testing packages:
291
+ - Create a virtual env and install required testing packages:
305
292
 
306
293
  ```
307
294
  python -m venv venv
@@ -309,27 +296,21 @@ To report a bug or request a new feature, please open an issue on [GitHub][githu
309
296
  pip install --editable --group dev --group test .
310
297
  ```
311
298
 
312
- Run all tests in the default Python environment:
299
+ - Run all tests in the default Python environment:
313
300
 
314
301
  ```
315
302
  pytest
316
303
  ```
317
304
 
318
- Run all tests, linting, and type checking across all supported/installed
319
- Python environments:
305
+ - Run all tests, linting, and type checking across all supported/installed
306
+ Python environments:
320
307
 
321
308
  ```
322
309
  tox
323
310
  ```
324
311
 
325
- 4. Commit and push your changes
326
-
327
- 5. Submit a [Pull Request][github-prs]
328
-
329
-
330
312
  [github-profile]: https://github.com/cgoldberg
331
313
  [github-repo]: https://github.com/cgoldberg/xvfbwrapper
332
- [github-issues]: https://github.com/cgoldberg/xvfbwrapper/issues
333
- [github-prs]: https://github.com/cgoldberg/xvfbwrapper/pulls
334
314
  [pypi-home]: https://pypi.org/project/xvfbwrapper
335
315
  [mit-license]: https://raw.githubusercontent.com/cgoldberg/xvfbwrapper/refs/heads/master/LICENSE
316
+ [api-docs]: https://coreygoldberg.com/xvfbwrapper
@@ -1,5 +1,6 @@
1
- # Corey Goldberg, 2012-2026
2
- # License: MIT
1
+ # Copyright (c) 2012-2026 Corey Goldberg
2
+ # SPDX-License-Identifier: MIT
3
+
3
4
 
4
5
  """Run a headless display inside X virtual framebuffer (Xvfb)."""
5
6
 
@@ -16,9 +17,9 @@ from random import randint
16
17
 
17
18
  try:
18
19
  import fcntl
19
- except ImportError:
20
+ except ImportError as e:
20
21
  system = platform.system()
21
- raise OSError(f"xvfbwrapper is not supported on this platform: {system}")
22
+ raise OSError(f"xvfbwrapper is not supported on this platform: {system}") from e
22
23
 
23
24
 
24
25
  class Xvfb:
@@ -60,7 +61,7 @@ class Xvfb:
60
61
  if not extra_args:
61
62
  extra_args = []
62
63
 
63
- self.extra_xvfb_args = [
64
+ self.extra_xvfb_args: list[str] = [
64
65
  "-screen",
65
66
  "0",
66
67
  f"{self.width}x{self.height}x{self.colordepth}",
@@ -134,7 +135,7 @@ class Xvfb:
134
135
 
135
136
  def _xvfb_exists(self) -> bool:
136
137
  """Check that Xvfb is available on PATH and is executable."""
137
- return True if shutil.which("Xvfb") is not None else False
138
+ return shutil.which("Xvfb") is not None
138
139
 
139
140
  def _cleanup_lock_file(self):
140
141
  """Delete lock files when stopping.
File without changes
File without changes
File without changes