From 6af2790bec397a053f41db9c9d83edddbe84a8d3 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 14 Aug 2022 14:53:46 -0400 Subject: [PATCH] Fix directive test on FreeBSD --- src/xdoctest/directive.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/xdoctest/directive.py b/src/xdoctest/directive.py index edba72bc..5591e315 100644 --- a/src/xdoctest/directive.py +++ b/src/xdoctest/directive.py @@ -120,21 +120,26 @@ Example: >>> import sys + >>> plat = sys.platform >>> count = 0 >>> # xdoctest: +REQUIRES(WIN32) - >>> assert sys.platform.startswith('win32') + >>> assert plat.startswith('win32'), 'this only runs on windows' >>> count += 1 >>> # xdoctest: -REQUIRES(WIN32) >>> # xdoctest: +REQUIRES(LINUX) - >>> assert sys.platform.startswith('linux') + >>> assert plat.startswith('linux'), 'this only runs on linux' >>> count += 1 >>> # xdoctest: -REQUIRES(LINUX) >>> # xdoctest: +REQUIRES(DARWIN) - >>> assert sys.platform.startswith('darwin') + >>> assert plat.startswith('darwin'), 'this only runs on osx' >>> count += 1 >>> # xdoctest: -REQUIRES(DARWIN) >>> print(count) - >>> assert count == 1, 'Exactly one of the above parts should have run' + >>> import sys + >>> if any(plat.startswith(n) for n in {'linux', 'win32', 'darwin'}): + >>> assert count == 1, 'Exactly one of the above parts should have run' + >>> else: + >>> assert count == 0, 'Nothing should have run on plat={}'.format(plat) >>> # xdoctest: +REQUIRES(--verbose) >>> print('This is only printed if you run with --verbose') @@ -705,7 +710,8 @@ def _is_requires_satisfied(arg, argv=None, environ=None): >>> _is_requires_satisfied('env:BAR>=1', argv=[], environ={'BAR': '0'}) """ # TODO: add python version options - SYS_PLATFORM_TAGS = ['win32', 'linux', 'darwin', 'cywgin'] + # https://docs.python.org/3/library/sys.html#sys.platform + SYS_PLATFORM_TAGS = ['win32', 'linux', 'darwin', 'cywgin', 'aix', 'freebsd'] OS_NAME_TAGS = ['posix', 'nt', 'java'] PY_IMPL_TAGS = ['cpython', 'ironpython', 'jython', 'pypy'] # TODO: tox tags: https://tox.readthedocs.io/en/latest/example/basic.html