Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# utcnow
tz_hour = time.timezone // 3600
utc_offset = str(tz_hour) if tz_hour < 0 else '+' + str(tz_hour)
stamp = time.strftime('%Y-%m-%dT%H%M%S') + utc_offset
return stamp
else:
raise ValueError('only iso8601 is accepted for now')
if __name__ == '__main__':
"""
CommandLine:
xdoctest -m ubelt.util_time
"""
import xdoctest as xdoc
xdoc.doctest_module(__file__)
# for optpart in options.split(','):
# if optpart:
# directive = parse_directive_optstr(optpart)
# if directive is not None:
# default_runtime_state[directive.name] = directive.positive
# # Specify a default doctest_example.Config state
# config = {
# 'default_runtime_state': default_runtime_state,
# offset_linenos = ns['offset_linenos']
# 'offset_linenos': offset_linenos,
# colored = ns['colored']
# 'colored': colored,
# }
xdoctest.doctest_module(modname, argv=[command], style=style,
config=config, durations=durations)
env = os.environ.copy()
env.update({'UBELT_TEST_ENV': '42'})
info = ub.cmd('echo $UBELT_TEST_ENV', env=env, shell=True)
print(info['out'])
assert info['out'].strip() == env['UBELT_TEST_ENV']
if __name__ == '__main__':
"""
pytest ubelt/tests/test_cmd.py -s
python ~/code/ubelt/ubelt/tests/test_cmd.py test_cmd_veryverbose
"""
import xdoctest
xdoctest.doctest_module(__file__)
>>> assert normal_version != codeblock_version
>>> print('Without codeblock')
>>> print(normal_version)
>>> print('With codeblock')
>>> print(codeblock_version)
"""
return textwrap.dedent(block_str).strip('\n')
if __name__ == '__main__':
"""
CommandLine:
python -m xdoctest.utils.util_str all
"""
import xdoctest
xdoctest.doctest_module(__file__)
some text
more text
even more text
""")
assert not status['passed']
if __name__ == '__main__':
"""
CommandLine:
export PYTHONPATH=$PYTHONPATH:/home/joncrall/code/xdoctest/testing
python ~/code/xdoctest/testing/test_core.py
pytest testing/test_core.py -vv
"""
import xdoctest # NOQA
xdoctest.doctest_module(__file__)
try:
import xxhash # NOQA
except ImportError:
pass
else:
assert ub.hash_data('foo', hasher='xxh64') == '33bf00a859c4ba3f'
if __name__ == '__main__':
r"""
CommandLine:
python ~/code/ubelt/ubelt/tests/test_hash.py
pytest ~/code/ubelt/ubelt/tests/test_hash.py
"""
import xdoctest
xdoctest.doctest_module(__file__)
"Return the minimum indentation of any non-blank line in `s`"
indents = [len(indent) for indent in INDENT_RE.findall(s)]
if len(indents) > 0:
return min(indents)
else:
return 0
if __name__ == '__main__':
"""
CommandLine:
python -m xdoctest.core
python -m xdoctest.parser all
"""
import xdoctest as xdoc
xdoc.doctest_module()
runner.doctest_module(modpath, 'foo', argv=[''], config=config)
assert 'SKIPPED' in cap.text
if __name__ == '__main__':
"""
CommandLine:
pytest testing/test_runner.py -s
pytest testing/test_runner.py -s
python testing/test_runner.py test_zero_args
"""
# import pytest
# pytest.main([__file__])
import xdoctest
xdoctest.doctest_module(__file__)
>>> modpath = modname_to_modpath(modname, hide_init=False, hide_main=False)
>>> print('modpath = %r' % (modpath,))
>>> assert modpath.endswith('__init__.py')
"""
from xdoctest import static_analysis as static
return static.modname_to_modpath(modname, hide_init, hide_main)
if __name__ == '__main__':
r"""
CommandLine:
python -m ubelt.meta.static_analysis
python -m ubelt.meta.static_analysis all
"""
import xdoctest as xdoc
xdoc.doctest_module()