Esempio n. 1
0
 def test_data(self):
     """Test data dir with XDG_DATA_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = utils.get_standard_dir(QStandardPaths.DataLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir, '.local',
                                                'share', 'qutebrowser'))
         self.assertTrue(os.path.exists(cur_dir))
Esempio n. 2
0
 def test_cache(self):
     """Test cache dir with XDG_CACHE_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = utils.get_standard_dir(QStandardPaths.CacheLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir, '.cache',
                                                'qutebrowser'))
         self.assertTrue(os.path.exists(cur_dir))
Esempio n. 3
0
 def test_config_explicit(self):
     """Test config dir with XDG_CONFIG_HOME explicitely set."""
     with helpers.environ_set_temp('XDG_CONFIG_HOME', self.temp_dir):
         cur_dir = utils.get_standard_dir(QStandardPaths.ConfigLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir,
                                                'qutebrowser'))
         self.assertTrue(os.path.exists(cur_dir))
Esempio n. 4
0
 def test_config_none(self):
     """Test initializing with config path set to None."""
     args = types.SimpleNamespace(confdir='')
     with helpers.environ_set_temp(self.env):
         standarddir.init(args)
         config.init()
     self.assertFalse(os.listdir(self.conf_path))
Esempio n. 5
0
 def test_config(self):
     """Test config dir with XDG_CONFIG_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = standarddir.get(
             QStandardPaths.ConfigLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir, '.config',
                                                'qutebrowser'))
 def test_data(self):
     """Test data dir with XDG_DATA_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.DataLocation)
         self.assertEqual(
             cur_dir,
             os.path.join(self.temp_dir, '.local', 'share', 'qutebrowser'))
Esempio n. 7
0
 def test_cache(self):
     """Test cache dir with XDG_CACHE_HOME not set."""
     env = {'HOME': self.temp_dir, 'XDG_CACHE_HOME': None}
     with helpers.environ_set_temp(env):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, '.cache', 'qutebrowser')
         self.assertEqual(standarddir.cache(), expected)
Esempio n. 8
0
 def test_data(self):
     """Test data dir with XDG_DATA_HOME not set."""
     env = {'HOME': self.temp_dir, 'XDG_DATA_HOME': None}
     with helpers.environ_set_temp(env):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, '.local', 'share',
                                 'qutebrowser')
         self.assertEqual(standarddir.data(), expected)
Esempio n. 9
0
 def test_environ_multiple(self):
     """Test environ_set_temp with multiple values."""
     os.environ['QUTEBROWSER_ENVIRON_TEST_1'] = 'oldval_1'
     os.environ['QUTEBROWSER_ENVIRON_TEST_3'] = 'oldval_3'
     env = {
         'QUTEBROWSER_ENVIRON_TEST_1': 'newval_1',
         'QUTEBROWSER_ENVIRON_TEST_2': 'newval_2',
         'QUTEBROWSER_ENVIRON_TEST_3': None,
     }
     with helpers.environ_set_temp(env):
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST_1'],
                          'newval_1')
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST_2'],
                          'newval_2')
         self.assertNotIn('QUTEBROWSER_ENVIRON_TEST_3', os.environ)
     self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST_1'], 'oldval_1')
     self.assertNotIn('QUTEBROWSER_ENVIRON_TEST_2', os.environ)
     self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST_3'], 'oldval_3')
Esempio n. 10
0
 def test_environ_unset(self):
     """Test environ_set_temp with something which wasn't set yet."""
     with helpers.environ_set_temp('QUTEBROWSER_ENVIRON_TEST', 'newval'):
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'newval')
     self.assertNotIn('QUTEBROWSER_ENVIRON_TEST', os.environ)
Esempio n. 11
0
 def test_environ_set(self):
     """Test environ_set_temp with something which was set already."""
     os.environ['QUTEBROWSER_ENVIRON_TEST'] = 'oldval'
     with helpers.environ_set_temp('QUTEBROWSER_ENVIRON_TEST', 'newval'):
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'newval')
     self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'oldval')
Esempio n. 12
0
 def test_environ_none_unset(self):
     """Test environ_set_temp with something which wasn't set yet."""
     with helpers.environ_set_temp({'QUTEBROWSER_ENVIRON_TEST': None}):
         self.assertNotIn('QUTEBROWSER_ENVIRON_TEST', os.environ)
     self.assertNotIn('QUTEBROWSER_ENVIRON_TEST', os.environ)
Esempio n. 13
0
 def test_cache_explicit(self):
     """Test cache dir with XDG_CACHE_HOME explicitely set."""
     with helpers.environ_set_temp('XDG_CACHE_HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.CacheLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir,
                                                'qutebrowser'))
Esempio n. 14
0
 def test_config(self):
     """Test config dir with XDG_CONFIG_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.ConfigLocation)
         self.assertEqual(
             cur_dir, os.path.join(self.temp_dir, '.config', 'qutebrowser'))
Esempio n. 15
0
 def test_data_explicit(self):
     """Test data dir with XDG_DATA_HOME explicitely set."""
     with helpers.environ_set_temp('XDG_DATA_HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.DataLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir,
                                                'qutebrowser'))
Esempio n. 16
0
 def test_cache(self):
     """Test cache dir with XDG_CACHE_HOME not set."""
     with helpers.environ_set_temp('HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.CacheLocation)
         self.assertEqual(
             cur_dir, os.path.join(self.temp_dir, '.cache', 'qutebrowser'))
Esempio n. 17
0
 def test_data_explicit(self):
     """Test data dir with XDG_DATA_HOME explicitly set."""
     with helpers.environ_set_temp({'XDG_DATA_HOME': self.temp_dir}):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, 'qutebrowser')
         self.assertEqual(standarddir.data(), expected)
Esempio n. 18
0
 def test_environ_set(self):
     """Test environ_set_temp with something which was set already."""
     os.environ['QUTEBROWSER_ENVIRON_TEST'] = 'oldval'
     with helpers.environ_set_temp('QUTEBROWSER_ENVIRON_TEST', 'newval'):
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'newval')
     self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'oldval')
Esempio n. 19
0
 def test_cache_explicit(self):
     """Test cache dir with XDG_CACHE_HOME explicitly set."""
     with helpers.environ_set_temp({'XDG_CACHE_HOME': self.temp_dir}):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, 'qutebrowser')
         self.assertEqual(standarddir.cache(), expected)
Esempio n. 20
0
 def test_environ_unset(self):
     """Test environ_set_temp with something which wasn't set yet."""
     with helpers.environ_set_temp('QUTEBROWSER_ENVIRON_TEST', 'newval'):
         self.assertEqual(os.environ['QUTEBROWSER_ENVIRON_TEST'], 'newval')
     self.assertNotIn('QUTEBROWSER_ENVIRON_TEST', os.environ)
Esempio n. 21
0
 def test_data_explicit(self):
     """Test data dir with XDG_DATA_HOME explicitely set."""
     with helpers.environ_set_temp('XDG_DATA_HOME', self.temp_dir):
         cur_dir = standarddir.get(QStandardPaths.DataLocation)
         self.assertEqual(cur_dir, os.path.join(self.temp_dir,
                                                'qutebrowser'))