-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from eighthave/patch-1
/run/user/$UID as fallback if XDG_RUNTIME_DIR is not set
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import datetime | ||
import os | ||
import unittest | ||
import tempfile | ||
from unittest import mock | ||
|
||
from podman import api | ||
|
||
|
||
class PathUtilsTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.xdg_runtime_dir = os.getenv('XDG_RUNTIME_DIR') | ||
print('XDG_RUNTIME_DIR', self.xdg_runtime_dir) | ||
|
||
@mock.patch.dict(os.environ, clear=True) | ||
def test_get_runtime_dir_env_var_set(self): | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
os.environ['XDG_RUNTIME_DIR'] = str(tmpdir) | ||
self.assertEqual(str(tmpdir), api.path_utils.get_runtime_dir()) | ||
|
||
@unittest.skipUnless(os.getenv('XDG_RUNTIME_DIR'), 'XDG_RUNTIME_DIR must be set') | ||
@mock.patch.dict(os.environ, clear=True) | ||
def test_get_runtime_dir_env_var_not_set(self): | ||
self.assertNotEqual(self.xdg_runtime_dir, api.path_utils.get_runtime_dir()) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |