initial commit
This commit is contained in:
		
						commit
						5872f210c9
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | venv* | ||||||
							
								
								
									
										1
									
								
								pytest.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								pytest.ini
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | junit_family = xunit1 | ||||||
							
								
								
									
										0
									
								
								src/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										19
									
								
								src/calculator.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/calculator.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | |||||||
|  | def add(a, b):  | ||||||
|  |     checkInputs(a, b)  | ||||||
|  |     return a + b  | ||||||
|  | 
 | ||||||
|  | def subtract(a, b):  | ||||||
|  |     checkInputs(a, b)  | ||||||
|  |     return a - b  | ||||||
|  | 
 | ||||||
|  | def multiply(a, b):  | ||||||
|  |     checkInputs(a, b)  | ||||||
|  |     return a * b  | ||||||
|  | 
 | ||||||
|  | def divide(a, b):  | ||||||
|  |     checkInputs(a, b)  | ||||||
|  |     return a / b  | ||||||
|  | 
 | ||||||
|  | def checkInputs(a, b):  | ||||||
|  |     if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):  | ||||||
|  |         raise TypeError("Inputs must be either int or float!") | ||||||
							
								
								
									
										10
									
								
								test_addition.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								test_addition.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | from src.calculator import add  | ||||||
|  | import pytest  | ||||||
|  | 
 | ||||||
|  | def test_add():  | ||||||
|  |     result = add(3, 4)  | ||||||
|  |     assert result == 7  | ||||||
|  | 
 | ||||||
|  | def test_add_string():  | ||||||
|  |     with pytest.raises(TypeError):  | ||||||
|  |         add("string", 4) | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user