Browse Source

python3.5: fixed TypeError due to start_engine passing pathlib.Path to subprocess.Popen for cwd

Fabian Peter Hammerle 3 years ago
parent
commit
c530db9c9e
3 changed files with 8 additions and 5 deletions
  1. 2 0
      CHANGELOG.md
  2. 2 4
      tests/test_api.py
  3. 4 1
      tooncher/__init__.py

+ 2 - 0
CHANGELOG.md

@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ## Unreleased
 ### Fixed
 - compatibility with python3.5:
+  - fixed `TypeError` due to `start_engine` passing `pathlib.Path`
+    to `subprocess.Popen` for `cwd`
   - tests: fixed `AttributeError` due to unavailable `MagicMock.assert_called_once`
 
 ## [1.0.2] - 2020-05-05

+ 2 - 4
tests/test_api.py

@@ -40,9 +40,7 @@ def test_start_engine_mac():
             "/Users/me/Library/Application Support/Toontown Rewritten/Toontown Rewritten"
         ],
         check=True,
-        cwd=pathlib.PosixPath(
-            "/Users/me/Library/Application Support/Toontown Rewritten"
-        ),
+        cwd="/Users/me/Library/Application Support/Toontown Rewritten",
         env={
             "SOME": "VAR",
             "OTHER": "VALUE",
@@ -68,7 +66,7 @@ def test_start_engine_xorg():
     popen_mock.assert_called_once_with(
         args=["/opt/toontown-rewritter/TTREngine"],
         check=False,
-        cwd=pathlib.PosixPath("/opt/toontown-rewritter"),
+        cwd="/opt/toontown-rewritter",
         env={
             "TTR_GAMESERVER": "gameserver.tld",
             "TTR_PLAYCOOKIE": "cookie123",

+ 4 - 1
tooncher/__init__.py

@@ -37,7 +37,10 @@ def start_engine(
         env["DYLD_LIBRARY_PATH"] = str(engine_path.parent.joinpath("Libraries.bundle"))
         env["DYLD_FRAMEWORK_PATH"] = str(engine_path.parent.joinpath("Frameworks"))
     return subprocess.Popen(
-        args=[str(engine_path)], cwd=engine_path.parent, env=env, **popen_kwargs,
+        args=[str(engine_path)],
+        cwd=str(engine_path.parent),  # str conversion for compatibility with python3.5
+        env=env,
+        **popen_kwargs,
     )