Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Unit testing module for table-like test, for Python 2.
For Python 3, check out TableTest3.
Many unit tests, especially those for side-effect free functions, can be written like this:
import unittest
class FooTest(unittest.TestCase):
TEST_CASES = [ case_1, case_2, ... ]
def test_all(self):
for test_case in TEST_CASES:
do something with test_case
If there are many test cases, they'll all appear as a single unit test in test runners. Furthermore, the failure of one test will cause all others to fail. Finally, it might be hard to identify which of the tests actually fail.
TableTest aims to solve this problem. Using it, we can rewrite the previous example as:
import tabletest
class FooTest(tabletest.TableTestCase):
TEST_CASES = [ case_1, case_2, ... ]
@tabletest.tabletest(TEST_CASES)
def test_all(self, test_case):
do something with test_case
When the testrunner will run this class, it will now find one test for each test case. Each test
will basically invoke tabletest
with a single test case.
The setup functions like this:
TEST_CASE
class variable which can be iterated as a sequence.TEST_CASE
generates a test function, called test_all_{xx}
, for the previous
example.unittest.TestCase
behavior remains intact: setUp
and tearDown
methods, other test
methods etc.test_
, so it is picked up by the runner.Installation is straightforward, via pip
:
pip install tabletest
Working on this project is pretty much standard Python development. Perhaps the most novel aspect is the usage of the Bazel build system. At the moment, only a py_library
, apy_test
and a pypi_package
are defined as build rules. Nevertheless, tests are run through Bazel rather than through regular invocation. To run the tests use:
bazel test //:tabletest_test
To push a new version of the package to PyPi use:
bazel run //:tabletest_upload -- --user=[pypi user] --pass=[pypi password]
See Tabletests and How Tabletest Works for a longer introduction as well as a deep dive into the library.
FAQs
Unit testing module for table-like test, for Python 2.
We found that tabletest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.