fix cod4 boolean handling #8
@@ -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 bool(value) is True else "0"
|
||||
return "1" if super().format_OT_BOOLEAN(value) is "True" else "0"
|
||||
|
||||
def close(self) -> None:
|
||||
self.cfgfile.close()
|
||||
|
||||
@@ -61,7 +61,7 @@ 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("17\n", capted_stdout.getvalue())
|
||||
self.assertEqual("", capted_stderr.getvalue())
|
||||
# check if other key still there / untouched
|
||||
# check if *other* key still there / untouched
|
||||
self.test_normal_READ_sv_mapRotation()
|
||||
|
||||
def test_defect_READ_net_port_NONEXISTS(self):
|
||||
@@ -74,3 +74,28 @@ class Testtest_cod4(unittest.TestCase):
|
||||
fct_main(["-g", "cod4", "-b", "test/tmp/COD4", "GetOption", "net_port"])
|
||||
self.assertEqual("132\n", capted_stdout.getvalue())
|
||||
self.assertEqual("", capted_stderr.getvalue())
|
||||
|
||||
def test_normal_WRITE_oldschool(self):
|
||||
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())
|
||||
|
||||
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
|
||||
fct_main(["-g", "cod4", "-b", "test/tmp/COD4", "SetOption", "oldschool", "0"])
|
||||
# /!\ 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: 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", "GetOption", "oldschool"])
|
||||
# /!\ 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())
|
||||
|
||||
Reference in New Issue
Block a user