This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testSuite1 = unittest.TestSuite() | |
| testSuite1.addTest(unittest.makeSuite(myTest1)) | |
| runner=unittest.TextTestRunner() | |
| runner.run(testSuite1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| loader = unittest.TestLoader() | |
| tests = loader.discover('.','test*') | |
| testRunner = unittest.runner.TextTestRunner() | |
| testRunner.run(tests) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def multiply (A,B): | |
| C = [[0,0,0],[0,0,0],[0,0,0]] | |
| for i in range(len(A)): | |
| for j in range(len(A[0])): | |
| for k in range(len(B)): | |
| C[i][j] += A[i][k] * B[k][j] | |
| return C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_multiply(self): | |
| A = [[1,1,1],[1,1,1],[1,1,1]] | |
| B = [[1,1,1],[1,1,1],[1,1,1]] | |
| product = [[3,3,3],[3,3,3],[3,3,3]] | |
| self.assertEqual(multiply(A,B),product) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from matrixOperations import add | |
| class TestMatrix(unittest.TestCase): | |
| def test_add(self): | |
| A = [[1,1,1],[1,1,1],[1,1,1]] | |
| B = [[1,1,1],[1,1,1],[1,1,1]] | |
| sum = [[2,2,2],[2,2,2],[2,2,2]] | |
| self.assertEqual(add(A,B),sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add(A,B): | |
| C = [[0,0,0],[0,0,0],[0,0,0]] | |
| for i in range(0,len(A)): | |
| for j in range(0,len(A[0])): | |
| C[i][j] = A[i][j] + B[i][j] | |
| return C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # in isCamelCase the regex now only matches keywords only | |
| # with constituent words starting in A-H | |
| x = re.search(r"(.+?)([A-H])",word) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_camelCaseSplit(self): | |
| self.assertEqual(camelCaseSplit("theDarkKnightRises"),["the","Dark","Knight","Rises"]) | |
| self.assertEqual(camelCaseSplit("helloW"),["hello","W"]) | |
| self.assertEqual(camelCaseSplit("helloIWorld"),["hello","I","World"]) | |
| with self.assertRaises(TypeError): | |
| camelCaseSplit(1234) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def camelCaseSplit(word): | |
| if (isCamelCase(word)): | |
| return re.split(r"(?=[A-Z])", word) | |
| else: | |
| return [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from abbreviation_generator import isCamelCase,camelCaseSplit | |
| class TestKeywords(unittest.TestCase): | |
| def test_isCamelCase(self): | |
| self.assertTrue(isCamelCase("janeDoe")) | |
| self.assertTrue(isCamelCase("imCamelCase")) | |
| self.assertTrue(isCamelCase("has$InWord")) | |
| self.assertFalse(isCamelCase("ImPascalCase")) | |
| self.assertFalse(isCamelCase("has_underscore")) |
NewerOlder