fix: cod4 bool again #9

Merged
chacha merged 1 commits from dev into master 2023-09-30 20:49:28 +02:00
2 changed files with 14 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ class GameOption_COD4(GameOption):
self.cfgfile = open(self.mainConfigFilePath, "r", encoding="utf8") # pylint: disable=consider-using-with
def format_OT_BOOLEAN(self, value: Union[int, str, float]) -> str:
return "1" if super().format_OT_BOOLEAN(value) is "True" else "0"
return "1" if super().format_OT_BOOLEAN(value).lower() == "true" else "0"
def close(self) -> None:
self.cfgfile.close()

View File

@@ -79,7 +79,7 @@ class Testtest_cod4(unittest.TestCase):
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
fct_main(["-g", "cod4", "-b", "test/tmp/COD4", "SetOption", "oldschool", "1"])
# /!\ add '\n' at the end of the string cause Python terminal newline is always this, regardless Windows / Linux os.linesep
# self.assertEqual("setting option <oldschool> to: 1\n", capted_stdout.getvalue())
self.assertEqual("setting option <oldschool> to: 1\n", capted_stdout.getvalue())
self.assertEqual("", capted_stderr.getvalue())
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
@@ -99,3 +99,15 @@ class Testtest_cod4(unittest.TestCase):
# /!\ add '\n' at the end of the string cause Python terminal newline is always this, regardless Windows / Linux os.linesep
self.assertEqual("0\n", capted_stdout.getvalue())
self.assertEqual("", capted_stderr.getvalue())
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
fct_main(["-g", "cod4", "-b", "test/tmp/COD4", "SetOption", "oldschool", "1"])
# /!\ add '\n' at the end of the string cause Python terminal newline is always this, regardless Windows / Linux os.linesep
self.assertEqual("setting option <oldschool> to: 1\n", capted_stdout.getvalue())
self.assertEqual("", capted_stderr.getvalue())
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
fct_main(["-g", "cod4", "-b", "test/tmp/COD4", "GetOption", "oldschool"])
# /!\ add '\n' at the end of the string cause Python terminal newline is always this, regardless Windows / Linux os.linesep
self.assertEqual("1\n", capted_stdout.getvalue())
self.assertEqual("", capted_stderr.getvalue())