mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Bail out early from tests if connection to the test db fails.
This commit is contained in:
		
							parent
							
								
									5f80dd38c4
								
							
						
					
					
						commit
						46a5f140c7
					
				| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#!/usr/bin/env python
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
from testutils import unittest
 | 
			
		||||
 | 
			
		||||
dbname = os.environ.get('PSYCOPG2_TESTDB', 'psycopg2_test')
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +32,17 @@ if dbport is not None:
 | 
			
		|||
if dbuser is not None:
 | 
			
		||||
    dsn += ' user=%s' % dbuser
 | 
			
		||||
 | 
			
		||||
# If connection to test db fails, bail out early.
 | 
			
		||||
import psycopg2
 | 
			
		||||
try:
 | 
			
		||||
    cnn = psycopg2.connect(dsn)
 | 
			
		||||
except Exception, e:
 | 
			
		||||
    print "Failed connection to test db:", e.__class__.__name__, e
 | 
			
		||||
    print "Please set env vars 'PSYCOPG2_TESTDB*' to valid values."
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
else:
 | 
			
		||||
    cnn.close()
 | 
			
		||||
 | 
			
		||||
import bugX000
 | 
			
		||||
import extras_dictcursor
 | 
			
		||||
import test_dates
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user