This reverts commit
c29407ab300f8ed54b5ca27cf4837c0aab920760.
This change breaks 'time' expression tests in py test suite. It looks
like with os.unshare, modifications to os.environ are lost. Neither
unshare module nor unshare command suffer from this problem.
Fixes: c29407ab300f8 ("tests: py: use `os.unshare` Python function")
Suggested-by: Jeremy Sowden <jeremy@azazel.net>
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
return [tests, passed, total_warning, total_error, total_unit_run]
def spawn_netns():
- # prefer stdlib unshare function ...
- try:
- os.unshare(os.CLONE_NEWNET)
- return True
- except Exception as e:
- pass
-
- # ... or unshare module
+ # prefer unshare module
try:
import unshare
unshare.unshare(unshare.CLONE_NEWNET)