Mailpile icon indicating copy to clipboard operation
Mailpile copied to clipboard

Reworking tests so they pass on Windows (and *nix)

Open noahhaasis opened this issue 7 years ago • 5 comments

The tests of the following functions will not pass because they assume unix paths: DirCheck
FileCheck
NewPathCheck PathCheck These are all in mailpile/config/validators.py

noahhaasis avatar May 19 '18 04:05 noahhaasis

Thank you for reporting this!

Hopefully someone who is comfortable with both Windows and Unix will fix the tests so they work on both sides.

BjarniRunar avatar Aug 07 '18 16:08 BjarniRunar

I thought a bit about possible solutions and the easiest that I can think of would look something like this:

from sys import platform 
...
"""
>>> on_windows = platform == 'win32'
>>> path = 'C:\\Users\\..\\' if on_windows else '/etc/../'
>>> abspath = 'C:\\' if on_windows else '/'
>>> PathCheck(path) == abspath
True
"""

I couldn’t test it yet because I currently don’t have access to a computer. I just wanted to throw this in to see what you think of this. Does it complicate the tests to much?

noahhaasis avatar Aug 24 '18 16:08 noahhaasis

That's actually relatively readable - I think that's a good approach. I'd merge that PR! :smile:

BjarniRunar avatar Sep 25 '18 16:09 BjarniRunar

Great. I'll start working on this

noahhaasis avatar Sep 25 '18 17:09 noahhaasis

TIL: Escaping a backslash in a doctest results in a error. They don't need to and mustn't be escaped.

noahhaasis avatar Oct 08 '18 05:10 noahhaasis