GitXplorerGitXplorer
h

error404

public
0 stars
0 forks
4 issues

Commits

List of commits on branch master.
Verified
f578230c25034e5e8a93a493d2414a05908d0f3b

Create label.yml

hharens committed 5 years ago
Verified
8778cdf18812f631553d43bd6536c02778d1d207

Create pythonpublish.yml

hharens committed 5 years ago
Verified
c7c60b18bb8c6b6fc101a6403e0df3f4a4885d45

Merge pull request #7 from harens/revert-6-harens-patch-1

hharens committed 5 years ago
Verified
cad15c0c5e70ce42ce0b3807401d0c8bb3aa6517

Revert "Create pythonpublish.yml"

hharens committed 5 years ago
Verified
df00bf304260c4c2112a1d066afc074f8f14e8f1

Merge pull request #6 from harens/harens-patch-1

hharens committed 5 years ago
Verified
090f11cdfd75efad79e8bfcc237872bae3236860

Create pythonpublish.yml

hharens committed 5 years ago

README

The README file for this repository.

error404

Downloads LGTM Grade PyPI - Python Version

An easy-to-use testing module, that doesn't require the terminal!

Example 1

Installation

pip install error404

Or download the project here

Usage

For the first parameter of the test function, insert the function and its input

Then, add the expected result:

test(some_function(function_input), expected_result)

Locally/In a file

This example produces the output shown above šŸ‘†

Only the test function has to be imported

test_results is run at the end to display how many succeeded

from error404 import test

# Example Functions
def add_one(number):
  return number + 1

def reverse_list(user_list):
  return user_list[::-1]
  
# Test Cases
test(add_one(4), 5) # Passes
test(add_one(6), "7") # Fails: Different type
test(add_one(232), 233) # Passes
test(add_one(-2), -1) # Passes

test(reverse_list([1, 2, 3]), [3, 2, 1]) # Passes
test(reverse_list([2, 3]), (3, 2)) # Fails: Different type

Interactive Mode

In interactive mode, you can still use just the test function

However, if you want to restart the counter, import clear_results, which is silent.

If you want to see the overall results, import test_results. This also runs clear_results afterwards.

from error404 import test, test_results
>>> def demo(greeting):
	return greeting

>>> test(demo('hi'), 'hi')
āœ… Function (1) Succeeded
>>> test(demo('bye'), 'hello')

āŒ Function (2) failed at line 1 in Interactive Mode
Program Output: bye (str)
Expected Output: hello (str)

>>> test_results()

Out of 2 tests, 1 succeeded and 1 failed in 0.4561 seconds
This gives a success rate of 50.0%

Jupyter Notebook/Google Colab

This works similar to a normal file. However, make sure to run test_results or clear_results (silent) at the end of the cell. Otherwise, the counter will continue in the following cells.

License

This project is licensed under the GNU General Public License v3.0