Skip to content

Commit

Permalink
Return an exit code from each test script (#696)
Browse files Browse the repository at this point in the history
* exit codes for tests

* revert unicode chars

* fix extended ascii chars
  • Loading branch information
keitherskine authored Feb 8, 2020
1 parent 46b3c99 commit 7825d53
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 25 deletions.
4 changes: 3 additions & 1 deletion tests2/accesstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,12 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

# Add the build directory to the path so we're testing the latest build, not the installed version.
add_to_path()
import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
8 changes: 5 additions & 3 deletions tests2/dbapitests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import sys
import unittest
from testutils import *
import dbapi20
Expand Down Expand Up @@ -38,6 +38,8 @@ def test_ExceptionsAsConnectionAttributes(self): pass
testRunner = unittest.TextTestRunner(verbosity=(options.verbose > 1) and 9 or 0)
result = testRunner.run(suite)

return result


if __name__ == '__main__':
main()

sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests2/exceltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

# Add the build directory to the path so we're testing the latest build, not the installed version.
add_to_path()
import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests2/informixtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1269,4 +1271,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests2/mysqltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -756,4 +758,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
5 changes: 4 additions & 1 deletion tests2/pgtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,14 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(s)

return result


if __name__ == '__main__':

# Add the build directory to the path so we're testing the latest build, not the installed version.

add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests2/sqldwtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1493,4 +1495,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 2 additions & 2 deletions tests2/sqlitetests.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

sys.exit(result.errors and 1 or 0)
return result


if __name__ == '__main__':
Expand All @@ -719,4 +719,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests2/sqlservertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1904,4 +1906,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/accesstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,12 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=args.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

# Add the build directory to the path so we're testing the latest build, not the installed version.
add_to_path()
import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
8 changes: 5 additions & 3 deletions tests3/dbapitests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import sys
import unittest
from testutils import *
import dbapi20
Expand Down Expand Up @@ -38,6 +38,8 @@ def test_ExceptionsAsConnectionAttributes(self): pass
testRunner = unittest.TextTestRunner(verbosity=(options.verbose > 1) and 9 or 0)
result = testRunner.run(suite)

return result


if __name__ == '__main__':
main()

sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/exceltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

# Add the build directory to the path so we're testing the latest build, not the installed version.
add_to_path()
import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/informixtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1258,4 +1260,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/mysqltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -787,4 +789,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
8 changes: 6 additions & 2 deletions tests3/pgtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Note: Be sure to use the "Unicode" (not the "ANSI") version of the PostgreSQL ODBC driver.
"""

import sys
import uuid
import unittest
from decimal import Decimal
Expand Down Expand Up @@ -702,7 +703,10 @@ def main():
s = unittest.TestSuite([ PGTestCase(connection_string, options.ansi, m) for m in methods ])

testRunner = unittest.TextTestRunner(verbosity=options.verbose)
testRunner.run(s)
result = testRunner.run(s)

return result


if __name__ == '__main__':

Expand All @@ -711,4 +715,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/sqldwtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1435,4 +1437,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 2 additions & 2 deletions tests3/sqlitetests.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

sys.exit(result.errors and 1 or 0)
return result


if __name__ == '__main__':
Expand All @@ -689,4 +689,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)
4 changes: 3 additions & 1 deletion tests3/sqlservertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,8 @@ def main():
testRunner = unittest.TextTestRunner(verbosity=options.verbose)
result = testRunner.run(suite)

return result


if __name__ == '__main__':

Expand All @@ -1829,4 +1831,4 @@ def main():
add_to_path()

import pyodbc
main()
sys.exit(0 if main().wasSuccessful() else 1)

0 comments on commit 7825d53

Please sign in to comment.