If you target multiple OSs, you most probably have to test your program on each of them. These tests should typically include running your test suite on the desired OS. So the straightforward solution for unit testing the above method is to adapt the expected result on
platform.system() exactly the same way you showed above:
if platform.system() == 'Darwin':
elif platform.system() == 'Linux':
elif platform.system() == 'Windows':
expectedResult="Seek advice on how to update."
Of course, the drawback is that you cannot get a full test coverage of your code when you run the tests on just one OS. In this example, this is probably acceptable, but if the "real" methods you want to test are more complicated, it may become more practicle to unit test the different parts without actually changing the OS. If that's the case, refactor the core part into a separate method which gets
platform.system() as a parameter:
if opSys == 'Darwin':
elif opSys == 'Linux':
elif opSys == 'Windows':
return "Seek advice on how to update."
Now you can write unit tests for
updateStringPerSystem, passing all os strings you like for different tests, allowing to test the different branches for OS1, OS2, OS3, etc. even when you are running your test suite only under OS1.
Note that this works only for basic unit tests. As soon as you want to test a function which actually uses the return value for
updateString in a OS dependent way, you cannot expect to test Windows functionality when running your suite under Linux, or vice versa.