def test_init_enable_long_path(self):
        self.dummy_value = 0

        def _read_windows_registry_mock(target_path):
            return self.dummy_value, "REG_DWORD"

        def _write_windows_registry_mock(target_path, value, dtype):
            self.dummy_value = value

        from conda.core import initialize
        orig_read_windows_registry = initialize._read_windows_registry
        initialize._read_windows_registry = _read_windows_registry_mock
        orig_write_windows_registry = initialize._write_windows_registry
        initialize._write_windows_registry = _write_windows_registry_mock
        orig_join = initialize.join
        initialize.join = ntpath.join

        try:
            target_path = r'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnabled'
            assert initialize._read_windows_registry(target_path)[0] == 0
            initialize.init_long_path(target_path)
            assert initialize._read_windows_registry(target_path)[0] == 1
        finally:
            initialize._read_windows_registry = orig_read_windows_registry
            initialize._write_windows_registry = orig_write_windows_registry
            initialize.join = orig_join
Exemplo n.º 2
0
    def test_init_enable_long_path(self):
        self.dummy_value = 0

        def _read_windows_registry_mock(target_path):
            return self.dummy_value, "REG_DWORD"

        def _write_windows_registry_mock(target_path, value, dtype):
            self.dummy_value = value

        from conda.core import initialize
        orig_read_windows_registry = initialize._read_windows_registry
        initialize._read_windows_registry = _read_windows_registry_mock
        orig_write_windows_registry = initialize._write_windows_registry
        initialize._write_windows_registry = _write_windows_registry_mock
        orig_join = initialize.join
        initialize.join = ntpath.join

        try:
            target_path = r'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnabled'
            assert initialize._read_windows_registry(target_path)[0] == 0
            initialize.init_long_path(target_path)
            assert initialize._read_windows_registry(target_path)[0] == 1
        finally:
            initialize._read_windows_registry = orig_read_windows_registry
            initialize._write_windows_registry = orig_write_windows_registry
            initialize.join = orig_join