Use pytest conventions consistently (#6337)

* Do not derive from unittest.TestCase (not needed for pytest)

* assertRaises -> pytest.raises

* Simplify test_empty_dmatrix with test parametrization

* setUpClass -> setup_class, tearDownClass -> teardown_class

* Don't import unittest; import pytest

* Use plain assert

* Use parametrized tests in more places

* Fix test_gpu_with_sklearn.py

* Put back run_empty_dmatrix_reg / run_empty_dmatrix_cls

* Fix test_eta_decay_gpu_hist

* Add parametrized tests for monotone constraints

* Fix test names

* Remove test parametrization

* Revise test_slice to be not flaky
This commit is contained in:
Philip Hyunsu Cho
2020-11-19 17:00:15 -08:00
committed by GitHub
parent c763b50dd0
commit 9c9070aea2
34 changed files with 200 additions and 223 deletions

View File

@@ -2,7 +2,6 @@ import xgboost as xgb
import pytest
import sys
import numpy as np
import unittest
sys.path.append("tests/python")
import testing as tm # noqa
@@ -33,8 +32,5 @@ def test_gpu_binary_classification():
assert err < 0.1
class TestGPUBoostFromPrediction(unittest.TestCase):
cpu_test = twskl.TestBoostFromPrediction()
def test_boost_from_prediction_gpu_hist(self):
self.cpu_test.run_boost_from_prediction('gpu_hist')
def test_boost_from_prediction_gpu_hist():
cpu_test = twskl.run_boost_from_prediction('gpu_hist')