Browse Source

tests / python3.5: fix AttributeError due to unavailable MagicMock.assert_called_once

https://github.com/fphammerle/switchbot-mqtt/pull/7/commits/38e23ba811de092e631a335148cecf22b858f533
https://github.com/fphammerle/ical2vdir/pull/10/commits/fb8f266966868557aa14f76e7c60d455d72a526f
Fabian Peter Hammerle 3 years ago
parent
commit
3668393c86
2 changed files with 8 additions and 5 deletions
  1. 3 0
      CHANGELOG.md
  2. 5 5
      tests/test_cli.py

+ 3 - 0
CHANGELOG.md

@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## Unreleased
+### Fixed
+- compatibility with python3.5:
+  - tests: fixed `AttributeError` due to unavailable `MagicMock.assert_called_once`
 
 ## [1.0.2] - 2020-05-05
 ### Fixed

+ 5 - 5
tests/test_cli.py

@@ -25,7 +25,7 @@ def test_cli_help():
 def test_engine_path_arg(run_mock):
     with patch("sys.argv", ["", "--engine-path", "/opt/ttr/TTREngine", "username"]):
         tooncher._cli.main()
-    run_mock.assert_called_once()
+    assert run_mock.call_count == 1
     args, kwargs = run_mock.call_args
     assert not args
     assert kwargs["engine_path"] == "/opt/ttr/TTREngine"
@@ -36,7 +36,7 @@ def test_engine_path_arg(run_mock):
 def test_engine_path_env(run_mock):
     with patch("sys.argv", ["", "username"]):
         tooncher._cli.main()
-    run_mock.assert_called_once()
+    assert run_mock.call_count == 1
     args, kwargs = run_mock.call_args
     assert not args
     assert kwargs["engine_path"] == "/opt/ttr/TTREnvine"
@@ -47,7 +47,7 @@ def test_engine_path_env(run_mock):
 def test_engine_path_arg_env(run_mock):
     with patch("sys.argv", ["", "--engine-path", "/opt/ttr/TTREngine", "username"]):
         tooncher._cli.main()
-    run_mock.assert_called_once()
+    assert run_mock.call_count == 1
     args, kwargs = run_mock.call_args
     assert not args
     assert kwargs["engine_path"] == "/opt/ttr/TTREngine"
@@ -67,7 +67,7 @@ def test_engine_path_config(launch_mock, tmpdir):
     )
     with patch("sys.argv", ["", "--config", config_file.strpath, "someone"]):
         tooncher._cli.main()
-    launch_mock.assert_called_once()
+    assert launch_mock.call_count == 1
     args, kwargs = launch_mock.call_args
     assert not args
     assert kwargs["engine_path"] == pathlib.Path("/opt/conf/TTR")
@@ -87,7 +87,7 @@ def test_engine_path_env_config(launch_mock, tmpdir):
     )
     with patch("sys.argv", ["", "--config", config_file.strpath, "someone"]):
         tooncher._cli.main()
-    launch_mock.assert_called_once()
+    assert launch_mock.call_count == 1
     args, kwargs = launch_mock.call_args
     assert not args
     assert kwargs["engine_path"] == pathlib.Path("/opt/ttr/TTREnvine")