Skip to main content

img

leetcode_tester

在leetcode做题时,感觉提交代码时,效率受制于网络。Leetcode的编辑器环境也不是很顺手,常常急躁提交留下失败的提交记录。 遂简单写了个本地测试框架,方便在本地进行测试。

安装方法

pip install leetcode-tester

使用方法

使用示例

from leetcode_tester import Tester


class Solution():
    def sfc(self, *args):
        # TODO: write your code here
        # Example:
        return sum(args)


if __name__ == '__main__':
    solution = Solution()
    test = Tester(solution.sfc)
    # TODO: add test case here
    # Example:
    test.addTest(1, 2, 3)
    test.addTest(2, 4, 6)
    test.doTest()

Solution类可以选择从Leetcode的编辑器中复制而来。当然,有些额外的特殊类型,还是需要自己补充。
Tester的addTest方法用于添加用例,最后一个入参会被作为期待结果,之前的参数会被作为入参传入Solution方法。

输出示例

Input: [1, 2, 3]
Expect: [3]
Result: [3]
Status: [RIGHT]
Exception: [None]
Cost: [7.152557373046875e-06]

Input: [2, 4, 6]
Expect: [6]
Result: [6]
Status: [RIGHT]
Exception: [None]
Cost: [3.0994415283203125e-06]

{'TOTAL': 2, 'RIGHT': 2, 'WRONG': 0, 'EXCEPTION': 0, 'TOTAL_COST': 1.0251998901367188e-05}

TODO

持续整理LeetCode中遇到的额外类型,例如:ListNode、TreeNode,并将其固化在这个包里以供用户直接使用。

Metadata

Release files for leetcode-tester 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leetcode-tester 1.0.7
File Size Uploaded Provenance Actions
leetcode_tester-1.0.7.tar.gz 3.7 kB Without provenance Details for leetcode_tester-1.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for leetcode-tester 1.0.7
File Interpreter ABI Platform Actions
leetcode_tester-1.0.7-py3-none-any.whl Python 3 none any Details for leetcode_tester-1.0.7-py3-none-any.whl

Total release size: 8.7 kB

Release files / leetcode_tester-1.0.7.tar.gz

Download URL leetcode_tester-1.0.7.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
87a4465d0da5a3b7327d64f75ddb1f496fcafb8769683be6a09ba223411c7f75
BLAKE2b-256 checksum
How to use checksums
22226c3689eadec905a6432fed715ef8efe302092ec6dc2c36ecdf52c2c691ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release files / leetcode_tester-1.0.7-py3-none-any.whl

Download URL leetcode_tester-1.0.7-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c3e18239d2084178c85557c59de582b7b7a5e01664cd9e3175ffeef3da0496e
BLAKE2b-256 checksum
How to use checksums
b6ef836e3d2837d377a23e9b51ba654e44711b9ec9665e44a54d711bdca46f9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Security for leetcode-tester 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page