Skip to content

Commit

Permalink
rename unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Jun 14, 2022
1 parent f86416f commit d5b37e9
Show file tree
Hide file tree
Showing 242 changed files with 371 additions and 366 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ requires = [

[tool.isort]
known_first_party = [
"docs",
"pl_examples",
"pytorch_lightning",
"tests",
"legacy",
"unittests",
]
profile = "black"
line_length = 120
Expand Down
7 changes: 0 additions & 7 deletions test/tests/helpers/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
SingleDeviceStrategy,
)
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.runif import RunIf
from unittests.helpers.runif import RunIf


def test_accelerator_choice_cpu(tmpdir):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pytorch_lightning.plugins.precision.precision_plugin import PrecisionPlugin
from pytorch_lightning.strategies import SingleDeviceStrategy
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel
from unittests.helpers.boring_model import BoringModel


def test_restore_checkpoint_after_pre_setup_default():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from pytorch_lightning import Trainer
from pytorch_lightning.accelerators import GPUAccelerator
from pytorch_lightning.accelerators.gpu import get_nvidia_gpu_stats
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


@RunIf(min_cuda_gpus=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from pytorch_lightning.strategies.single_hpu import SingleHPUStrategy
from pytorch_lightning.utilities import _HPU_AVAILABLE
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.runif import RunIf
from tests.helpers.simple_models import ClassificationModel
from unittests.helpers.boring_model import BoringModel
from unittests.helpers.datamodules import ClassifDataModule
from unittests.helpers.runif import RunIf
from unittests.helpers.simple_models import ClassificationModel


@RunIf(hpu=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
from pytorch_lightning.trainer.supporters import CombinedLoader
from pytorch_lightning.utilities import _IPU_AVAILABLE
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.runif import RunIf
from tests.helpers.simple_models import ClassificationModel
from unittests.helpers.boring_model import BoringModel
from unittests.helpers.datamodules import ClassifDataModule
from unittests.helpers.runif import RunIf
from unittests.helpers.simple_models import ClassificationModel

if _IPU_AVAILABLE:
import poptorch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from pytorch_lightning.plugins import PrecisionPlugin, TPUPrecisionPlugin, XLACheckpointIO
from pytorch_lightning.strategies import DDPStrategy, TPUSpawnStrategy
from pytorch_lightning.utilities import find_shared_parameters
from tests.helpers.boring_model import BoringModel, RandomDataset
from tests.helpers.runif import RunIf
from tests.helpers.utils import pl_multi_process_test
from unittests.helpers.boring_model import BoringModel, RandomDataset
from unittests.helpers.runif import RunIf
from unittests.helpers.utils import pl_multi_process_test


class WeightSharingModule(BoringModel):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
import os

from tests.benchmarks.test_basic_parity import measure_loops
from tests.helpers.advanced_models import ParityModuleMNIST, ParityModuleRNN
from unittests.benchmarks.test_basic_parity import measure_loops
from unittests.helpers.advanced_models import ParityModuleMNIST, ParityModuleRNN

NUM_EPOCHS = 20
NUM_RUNS = 50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tqdm import tqdm

from pytorch_lightning import LightningModule, seed_everything, Trainer
from tests.helpers.advanced_models import ParityModuleCIFAR, ParityModuleMNIST, ParityModuleRNN
from unittests.helpers.advanced_models import ParityModuleCIFAR, ParityModuleMNIST, ParityModuleRNN

_EXTEND_BENCHMARKS = os.getenv("PL_RUNNING_BENCHMARKS", "0") == "1"
_SHORT_BENCHMARKS = not _EXTEND_BENCHMARKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from pytorch_lightning import seed_everything, Trainer
from pytorch_lightning.strategies import DDPSpawnShardedStrategy
from tests.helpers.boring_model import BoringModel, RandomDataset
from tests.helpers.runif import RunIf
from unittests.helpers.boring_model import BoringModel, RandomDataset
from unittests.helpers.runif import RunIf


class SeedTrainLoaderModel(BoringModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from torch.utils.data import DataLoader, DistributedSampler

from pytorch_lightning import LightningModule, seed_everything, Trainer
from tests.helpers.runif import RunIf
from unittests.helpers.runif import RunIf


class SyncBNModule(LightningModule):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytest

from pytorch_lightning import Callback, Trainer
from tests.helpers.boring_model import BoringModel
from unittests.helpers.boring_model import BoringModel


@pytest.mark.parametrize("single_cb", [False, True])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

from pytorch_lightning import Callback, Trainer
from pytorch_lightning.callbacks import ModelCheckpoint
from tests.helpers import BoringModel
from tests.helpers.utils import no_warning_call
from unittests.helpers import BoringModel
from unittests.helpers.utils import no_warning_call


def test_callbacks_configured_in_model(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from pytorch_lightning.loggers import CSVLogger
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.rank_zero import rank_zero_only
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


@RunIf(min_cuda_gpus=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
from pytorch_lightning import seed_everything, Trainer
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.runif import RunIf
from tests.helpers.simple_models import ClassificationModel
from unittests.helpers import BoringModel
from unittests.helpers.datamodules import ClassifDataModule
from unittests.helpers.runif import RunIf
from unittests.helpers.simple_models import ClassificationModel

_logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytorch_lightning import LightningModule, seed_everything, Trainer
from pytorch_lightning.callbacks import BackboneFinetuning, BaseFinetuning, ModelCheckpoint
from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_11
from tests.helpers import BoringModel, RandomDataset
from unittests.helpers import BoringModel, RandomDataset


class TestBackboneFinetuningCallback(BackboneFinetuning):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import GradientAccumulationScheduler
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from unittests.helpers import BoringModel


@pytest.mark.parametrize("accumulate_grad_batches", (1, 2, 3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from pytorch_lightning import seed_everything, Trainer
from pytorch_lightning.callbacks import Callback, LambdaCallback
from tests.helpers.boring_model import BoringModel
from tests.models.test_hooks import get_members
from unittests.helpers.boring_model import BoringModel
from unittests.models.test_hooks import get_members


def test_lambda_call(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import torch
from torch import optim

import tests.helpers.utils as tutils
import unittests.helpers.utils as tutils
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import LearningRateMonitor
from pytorch_lightning.callbacks.callback import Callback
from pytorch_lightning.callbacks.finetuning import BackboneFinetuning
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.simple_models import ClassificationModel
from unittests.helpers import BoringModel
from unittests.helpers.datamodules import ClassifDataModule
from unittests.helpers.simple_models import ClassificationModel


def test_lr_monitor_single_lr(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ModelSummary
from tests.helpers.boring_model import BoringModel
from unittests.helpers.boring_model import BoringModel


def test_model_summary_callback_present_trainer():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from pytorch_lightning.callbacks import BasePredictionWriter
from pytorch_lightning.trainer.supporters import CombinedLoader
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel, RandomDataset
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel, RandomDataset
from unittests.helpers.runif import RunIf


class DummyPredictionWriter(BasePredictionWriter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ModelCheckpoint, ModelPruning
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers.boring_model import BoringModel
from unittests.helpers.runif import RunIf


class TestModel(BoringModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from pytorch_lightning.callbacks import QuantizationAwareTraining
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.memory import get_model_size_mb
from tests.helpers.boring_model import RandomDataset
from tests.helpers.datamodules import RegressDataModule
from tests.helpers.runif import RunIf
from tests.helpers.simple_models import RegressionModel
from unittests.helpers.boring_model import RandomDataset
from unittests.helpers.datamodules import RegressDataModule
from unittests.helpers.runif import RunIf
from unittests.helpers.simple_models import RegressionModel


@pytest.mark.parametrize("observe", ["average", "histogram"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import RichModelSummary, RichProgressBar
from pytorch_lightning.utilities.model_summary import summarize
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


@RunIf(rich=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ProgressBarBase, RichProgressBar
from pytorch_lightning.callbacks.progress.rich_progress import RichProgressBarTheme
from tests.helpers.boring_model import BoringModel, RandomDataset, RandomIterableDataset
from tests.helpers.runif import RunIf
from unittests.helpers.boring_model import BoringModel, RandomDataset, RandomIterableDataset
from unittests.helpers.runif import RunIf


@RunIf(rich=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from pytorch_lightning.callbacks import StochasticWeightAveraging
from pytorch_lightning.strategies import DDPSpawnStrategy, Strategy
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel, RandomDataset, RandomIterableDataset
from tests.helpers.runif import RunIf
from unittests.helpers.boring_model import BoringModel, RandomDataset, RandomIterableDataset
from unittests.helpers.runif import RunIf


class SwaTestModel(BoringModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.callbacks.timer import Timer
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


def test_trainer_flag(caplog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from pytorch_lightning.callbacks.progress.tqdm_progress import Tqdm
from pytorch_lightning.core.module import LightningModule
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel, RandomDataset
from tests.helpers.runif import RunIf
from unittests.helpers.boring_model import BoringModel, RandomDataset
from unittests.helpers.runif import RunIf


class MockTqdm(Tqdm):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import torch

from pytorch_lightning import callbacks, Trainer
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


def test_disabled_checkpointing(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import pytorch_lightning as pl
from pytorch_lightning import Callback, Trainer
from tests import _PATH_LEGACY, _PROJECT_ROOT
from unittests import _PATH_LEGACY, _PROJECT_ROOT

LEGACY_CHECKPOINTS_PATH = os.path.join(_PATH_LEGACY, "checkpoints")
CHECKPOINT_EXTENSION = ".ckpt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
from torch import optim

import pytorch_lightning as pl
import tests.helpers.utils as tutils
import unittests.helpers.utils as tutils
from pytorch_lightning import seed_everything, Trainer
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import TensorBoardLogger
from pytorch_lightning.utilities.cloud_io import load as pl_load
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.imports import _OMEGACONF_AVAILABLE
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf

if _OMEGACONF_AVAILABLE:
from omegaconf import Container, OmegaConf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import torch

from pytorch_lightning import Trainer
from tests.helpers import BoringModel
from tests.helpers.runif import RunIf
from unittests.helpers import BoringModel
from unittests.helpers.runif import RunIf


def test_model_torch_save(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.plugins.io.torch_plugin import TorchCheckpointIO
from pytorch_lightning.plugins.io.xla_plugin import XLACheckpointIO
from tests.helpers import BoringModel
from unittests.helpers import BoringModel


def test_finetuning_with_ckpt_path(tmpdir):
Expand Down
2 changes: 1 addition & 1 deletion test/tests/conftest.py → test/unittests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pytorch_lightning.plugins.environments.lightning_environment import find_free_network_port
from pytorch_lightning.trainer.connectors.signal_connector import SignalConnector
from pytorch_lightning.utilities.imports import _IS_WINDOWS
from tests import _PATH_DATASETS
from unittests import _PATH_DATASETS


@pytest.fixture(scope="session")
Expand Down
File renamed without changes.
Loading

0 comments on commit d5b37e9

Please sign in to comment.