Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] [ci] Refactor tests to use pytest style #3732

Closed
jameslamb opened this issue Jan 5, 2021 · 2 comments · Fixed by #3844
Closed

[python] [ci] Refactor tests to use pytest style #3732

jameslamb opened this issue Jan 5, 2021 · 2 comments · Fixed by #3844

Comments

@jameslamb
Copy link
Collaborator

Summary

The tests on the Python package currently use two different styles.

The dask tests for example, use the pytest style, where each test case is a function and conditions are checked by assert-ing

def test_classifier(output, centers, client, listen_port):
    ....
    assert_eq(s1, s2)
    assert_eq(p1, p2)

While the 'engine' tests use the traditional unittest style, where each test case is a method on a class that inherits from unittest.TestCase and conditions are checked with unittest builtin methods.

class TestEngine(unittest.TestCase):
    def test_binary(self):
        ...
        self.assertLess(ret, 0.14)
        self.assertEqual(len(evals_result['valid_0']['binary_logloss']), 50)

To close this issue, change all of the tests to the pytest style. You'll know you've been successful if none of the test files need to import unittest.

Motivation

This consistency will make contributing on LightGBM easier. This is especially important in the Python project, which is often used to indirectly test changes at the C++ side (for example, #3299 ).

Description

This change should be applied for all test modules in tests/python_package_test. Please avoid changing any of the test logic and just focus on style.

If you get stuck, @ me here and I can help.

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Jan 15, 2021

  • test_basic.py
  • test_consistency.py
  • test_dask.py
  • test_dual.py
  • test_engine.py
  • test_plotting.py
  • test_sklearn.py

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants