A simple library to help people run Leetcode testcases without the Leetcode online IDE.
Project description
leetcodeDriverPY
A simple driver to allow you to use testcases in your own code :)
If you would like to use this in your project, its a simple as
just doing pip install leetcodeDriverPY
Then once you have done that inside of your python file you will want to do something like this:
top of the file:
from leetcodeDriverPY import driver
inbetween these two segments of code should be your solution class with the solution function inside.
sol = Solution() # this should be your solution class
testcases = { # create by doing: 'testcase': answer
'answer': 'correct_solution',
}
driver(sol, testcases)
# ^ sol should be your Solution class
# testcases should be the testcases that you want to use to test your program.
If you class has more than one function inside you may run into issues, for that reason I added a "optionalFunc" parameter.
This would be how you use it:
# this code is just the code from above but changed to use optionalFunc
sol = Solution() # this should be your solution class
testcases = { # create by doing: 'testcase': answer
'answer': 'correct_solution',
}
driver(sol, testcases, optionalFunc=sol.IntToRoman)
# ^ optionalFunc should be your function REFERENCE! (ex: sol.IntToRoman)
# You shouldn't actually call the function.
Change Log
0.0.1 (12/30/2022)
- First Release
0.0.2 (12/30/2022)
- I forgot to actually make it work
0.0.3 (12/31/2022)
- I actually did stuff???
- Removed legacy code.
- Added verification to ensure that the correct parameters are filled.
- Separated the big init file into some smaller files.
- Changed the error text from FunctionNotFound.
- Added "optionalFunc" parameter, incase you needed to give a direct reference to your function.
- Updated the README.md to show how to use the optionalFunc parameter.
- Added a print statement to inform you of what function is being used.
- Added a NotEnoughTestcases Error.
- Added a check to confirm that len(testcases) > 1 if it fails then it raises NotEnoughTestcases.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file leetcodeDriverPY-0.0.3.tar.gz
.
File metadata
- Download URL: leetcodeDriverPY-0.0.3.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1f36a3a803aba501023a1d7a57e15d2c288232ed44fa4d4812dcd94864dc21e |
|
MD5 | 596ca63a0ffd663981c911ed4a45db06 |
|
BLAKE2b-256 | fa7ece9e8839197049103ee6026f6639a024dc27f44cdfba22152881b56df406 |