Correct pytest.raises matches to match (#15346)
This commit is contained in:
		 Massimiliano Culpo
					Massimiliano Culpo
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							d9626cca50
						
					
				
				
					commit
					752092f46a
				
			| @@ -755,7 +755,7 @@ def test_query_spec_with_non_conditional_virtual_dependency(database): | |||||||
| def test_failed_spec_path_error(database): | def test_failed_spec_path_error(database): | ||||||
|     """Ensure spec not concrete check is covered.""" |     """Ensure spec not concrete check is covered.""" | ||||||
|     s = spack.spec.Spec('a') |     s = spack.spec.Spec('a') | ||||||
|     with pytest.raises(ValueError, matches='Concrete spec required'): |     with pytest.raises(ValueError, match='Concrete spec required'): | ||||||
|         spack.store.db._failed_spec_path(s) |         spack.store.db._failed_spec_path(s) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -245,7 +245,7 @@ def test_ensure_locked_have(install_mockery, tmpdir): | |||||||
| def test_package_id(install_mockery): | def test_package_id(install_mockery): | ||||||
|     """Test to cover package_id functionality.""" |     """Test to cover package_id functionality.""" | ||||||
|     pkg = spack.repo.get('trivial-install-test-package') |     pkg = spack.repo.get('trivial-install-test-package') | ||||||
|     with pytest.raises(ValueError, matches='spec is not concretized'): |     with pytest.raises(ValueError, match='spec is not concretized'): | ||||||
|         inst.package_id(pkg) |         inst.package_id(pkg) | ||||||
| 
 | 
 | ||||||
|     spec = spack.spec.Spec('trivial-install-test-package') |     spec = spack.spec.Spec('trivial-install-test-package') | ||||||
| @@ -280,7 +280,7 @@ def _no_compilers(pkg, arch_spec): | |||||||
| 
 | 
 | ||||||
|     # Test up to the dependency check |     # Test up to the dependency check | ||||||
|     monkeypatch.setattr(spack.compilers, 'compilers_for_spec', _no_compilers) |     monkeypatch.setattr(spack.compilers, 'compilers_for_spec', _no_compilers) | ||||||
|     with pytest.raises(spack.repo.UnknownPackageError, matches='not found'): |     with pytest.raises(spack.repo.UnknownPackageError, match='not found'): | ||||||
|         inst._packages_needed_to_bootstrap_compiler(spec.package) |         inst._packages_needed_to_bootstrap_compiler(spec.package) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @@ -300,7 +300,7 @@ def test_check_deps_status_errs(install_mockery, monkeypatch): | |||||||
|     orig_fn = spack.database.Database.prefix_failed |     orig_fn = spack.database.Database.prefix_failed | ||||||
|     monkeypatch.setattr(spack.database.Database, 'prefix_failed', _true) |     monkeypatch.setattr(spack.database.Database, 'prefix_failed', _true) | ||||||
| 
 | 
 | ||||||
|     with pytest.raises(inst.InstallError, matches='install failure'): |     with pytest.raises(inst.InstallError, match='install failure'): | ||||||
|         installer._check_deps_status() |         installer._check_deps_status() | ||||||
| 
 | 
 | ||||||
|     monkeypatch.setattr(spack.database.Database, 'prefix_failed', orig_fn) |     monkeypatch.setattr(spack.database.Database, 'prefix_failed', orig_fn) | ||||||
| @@ -308,7 +308,7 @@ def test_check_deps_status_errs(install_mockery, monkeypatch): | |||||||
|     # Ensure do not acquire the lock |     # Ensure do not acquire the lock | ||||||
|     monkeypatch.setattr(inst.PackageInstaller, '_ensure_locked', _not_locked) |     monkeypatch.setattr(inst.PackageInstaller, '_ensure_locked', _not_locked) | ||||||
| 
 | 
 | ||||||
|     with pytest.raises(inst.InstallError, matches='write locked by another'): |     with pytest.raises(inst.InstallError, match='write locked by another'): | ||||||
|         installer._check_deps_status() |         installer._check_deps_status() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @@ -506,7 +506,7 @@ def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys): | |||||||
|     monkeypatch.setattr(inst.PackageInstaller, '_update_failed', _noop) |     monkeypatch.setattr(inst.PackageInstaller, '_update_failed', _noop) | ||||||
| 
 | 
 | ||||||
|     msg = 'Cannot proceed with dependent-install' |     msg = 'Cannot proceed with dependent-install' | ||||||
|     with pytest.raises(spack.installer.InstallError, matches=msg): |     with pytest.raises(spack.installer.InstallError, match=msg): | ||||||
|         installer.install() |         installer.install() | ||||||
| 
 | 
 | ||||||
|     out = str(capsys.readouterr()) |     out = str(capsys.readouterr()) | ||||||
| @@ -524,7 +524,7 @@ def test_install_failed(install_mockery, monkeypatch, capsys): | |||||||
|     monkeypatch.setattr(inst.PackageInstaller, '_install_task', _noop) |     monkeypatch.setattr(inst.PackageInstaller, '_install_task', _noop) | ||||||
| 
 | 
 | ||||||
|     msg = 'Installation of b failed' |     msg = 'Installation of b failed' | ||||||
|     with pytest.raises(spack.installer.InstallError, matches=msg): |     with pytest.raises(spack.installer.InstallError, match=msg): | ||||||
|         installer.install() |         installer.install() | ||||||
| 
 | 
 | ||||||
|     out = str(capsys.readouterr()) |     out = str(capsys.readouterr()) | ||||||
| @@ -643,7 +643,7 @@ def _install(installer, task, **kwargs): | |||||||
| 
 | 
 | ||||||
|     spec, installer = create_installer('b') |     spec, installer = create_installer('b') | ||||||
| 
 | 
 | ||||||
|     with pytest.raises(dl.InstallDirectoryAlreadyExistsError, matches=err): |     with pytest.raises(dl.InstallDirectoryAlreadyExistsError, match=err): | ||||||
|         installer.install() |         installer.install() | ||||||
| 
 | 
 | ||||||
|     assert 'b' in installer.installed |     assert 'b' in installer.installed | ||||||
|   | |||||||
| @@ -1272,7 +1272,7 @@ def test_downgrade_write_fails(tmpdir): | |||||||
|         lock = lk.Lock('lockfile') |         lock = lk.Lock('lockfile') | ||||||
|         lock.acquire_read() |         lock.acquire_read() | ||||||
|         msg = 'Cannot downgrade lock from write to read on file: lockfile' |         msg = 'Cannot downgrade lock from write to read on file: lockfile' | ||||||
|         with pytest.raises(lk.LockDowngradeError, matches=msg): |         with pytest.raises(lk.LockDowngradeError, match=msg): | ||||||
|             lock.downgrade_write_to_read() |             lock.downgrade_write_to_read() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @@ -1292,5 +1292,5 @@ def test_upgrade_read_fails(tmpdir): | |||||||
|         lock = lk.Lock('lockfile') |         lock = lk.Lock('lockfile') | ||||||
|         lock.acquire_write() |         lock.acquire_write() | ||||||
|         msg = 'Cannot upgrade lock from read to write on file: lockfile' |         msg = 'Cannot upgrade lock from read to write on file: lockfile' | ||||||
|         with pytest.raises(lk.LockUpgradeError, matches=msg): |         with pytest.raises(lk.LockUpgradeError, match=msg): | ||||||
|             lock.upgrade_read_to_write() |             lock.upgrade_read_to_write() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user