mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#364 Attach user_dir to settings
				
					
				
			This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| from pathlib import Path | ||||
| import pytest | ||||
| from thefuck import conf | ||||
|  | ||||
| @@ -16,7 +17,12 @@ def no_memoize(monkeypatch): | ||||
|  | ||||
| @pytest.fixture(autouse=True) | ||||
| def settings(request): | ||||
|     request.addfinalizer(lambda: conf.settings.update(conf.DEFAULT_SETTINGS)) | ||||
|     def _reset_settings(): | ||||
|         conf.settings.clear() | ||||
|         conf.settings.update(conf.DEFAULT_SETTINGS) | ||||
|  | ||||
|     request.addfinalizer(_reset_settings) | ||||
|     conf.settings.user_dir = Path('~/.thefuck') | ||||
|     return conf.settings | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,7 @@ class TestGetRules(object): | ||||
|     @pytest.fixture | ||||
|     def glob(self, mocker): | ||||
|         results = {} | ||||
|         mocker.patch('thefuck.corrector.Path.glob', | ||||
|         mocker.patch('pathlib.Path.glob', | ||||
|                      new_callable=lambda: lambda *_: results.pop('value', [])) | ||||
|         return lambda value: results.update({'value': value}) | ||||
|  | ||||
| @@ -54,7 +54,7 @@ class TestGetRules(object): | ||||
|         settings.update(rules=self._prepare_rules(conf_rules), | ||||
|                         priority={}, | ||||
|                         exclude_rules=self._prepare_rules(exclude_rules)) | ||||
|         rules = corrector.get_rules(Path('~')) | ||||
|         rules = corrector.get_rules() | ||||
|         self._compare_names(rules, loaded_rules) | ||||
|  | ||||
|  | ||||
| @@ -98,5 +98,5 @@ def test_get_corrected_commands(mocker): | ||||
|                   get_new_command=lambda x: [x.script + '@', x.script + ';'], | ||||
|                   priority=60)] | ||||
|     mocker.patch('thefuck.corrector.get_rules', return_value=rules) | ||||
|     assert [cmd.script for cmd in get_corrected_commands(command, None)] \ | ||||
|     assert [cmd.script for cmd in get_corrected_commands(command)] \ | ||||
|            == ['test!', 'test@', 'test;'] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user