<commit_before>from datetime import datetime
import unittest

import _mssql

class ErrHandleTests(unittest.TestCase):

	def test01DBError(self):
		connection = None
		severity = 8
		dberr = 101
		oserr = 0
		dberrstr = "toblerone1"
		oserrstr = None
		
		expect = "DB-Lib error message %d, severity %d:\n%s\n" % ( dberr, severity, dberrstr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test02OSError(self):
		connection = None
		# EXCOMM
		severity = 9
		dberr = 102
		oserr = 1001
		dberrstr = "toblerone2"
		oserrstr = "scorpion"
		
		expect = "DB-Lib error message %d, severity %d:\n%s\nNet-Lib error during %s (%d)\n" % ( 
			dberr, severity, dberrstr, oserrstr, oserr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test03OSError(self):
		connection = None
		severity = 10
		dberr = 103
		oserr = 1003
		dberrstr = "toblerone3"
		oserrstr = "cabezon"
		
		expect = "DB-Lib error message %d, severity %d:\n%s\nOperating System error during %s (%d)\n" % ( 
			dberr, severity, dberrstr, oserrstr, oserr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test04OSError(self):
		connection = None

		# smaller than min error severity, so no output should be generated
		severity = 5
		dberr = 10
		oserr = 4444
		dberrstr = "toblerone4"
		oserrstr = "limpet"
		
		expect = "" 
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

if __name__ == "__main__":
	unittest.main()<commit_msg>renamed err handler test case and added newline<commit_after>from datetime import datetime
import unittest

import _mssql

class ErrHandleTests(unittest.TestCase):

	def test01DBError(self):
		connection = None
		severity = 8
		dberr = 101
		oserr = 0
		dberrstr = "toblerone1"
		oserrstr = None
		
		expect = "DB-Lib error message %d, severity %d:\n%s\n" % ( dberr, severity, dberrstr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test02OSError(self):
		connection = None
		# EXCOMM
		severity = 9
		dberr = 102
		oserr = 1001
		dberrstr = "toblerone2"
		oserrstr = "scorpion"
		
		expect = "DB-Lib error message %d, severity %d:\n%s\nNet-Lib error during %s (%d)\n" % ( 
			dberr, severity, dberrstr, oserrstr, oserr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test03OSError(self):
		connection = None
		severity = 10
		dberr = 103
		oserr = 1003
		dberrstr = "toblerone3"
		oserrstr = "cabezon"
		
		expect = "DB-Lib error message %d, severity %d:\n%s\nOperating System error during %s (%d)\n" % ( 
			dberr, severity, dberrstr, oserrstr, oserr )
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

	def test04NoError(self):
		connection = None

		# smaller than min error severity, so no output should be generated
		severity = 5
		dberr = 10
		oserr = 4444
		dberrstr = "toblerone4"
		oserrstr = "limpet"
		
		expect = "" 
        
		values = _mssql.test_err_handler( connection, severity, dberr, oserr, dberrstr, oserrstr )
		self.assertEqual( values[0] , 2 )
		self.assertEqual( values[1] , expect )

if __name__ == "__main__":
	unittest.main()
{'fraction_non_alphanumeric': 0.11202466598150052, 'fraction_numerical': 0.02723535457348407, 'mean_word_length': 3.5267441860465114, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1518881', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1439, 'n_words': 370}