Skip to content

Latest commit

 

History

History
100 lines (61 loc) · 2.87 KB

File metadata and controls

100 lines (61 loc) · 2.87 KB

Test Module Import

Since testcontainers-python :material-tag: v4.7.0

Introduction

The Testcontainers module for testing Python module imports and package management. This module provides a containerized environment for testing various aspects of Python module imports, including:

  • Basic module and package imports
  • Module reloading
  • Version-specific imports
  • Dependencies and environment variables
  • Advanced features like custom loaders and namespace packages

Adding this module to your project dependencies

Please run the following command to add the Test Module Import module to your python dependencies:

pip install testcontainers[test_module_import]

Usage examples

The module provides several examples demonstrating different use cases:

Basic Module Imports

This example demonstrates the fundamental capabilities of the TestModuleImportContainer:

  • Importing a basic Python module and accessing its attributes
  • Importing and using submodules
  • Importing and working with packages
  • Proper cleanup of imported modules

Basic module imports

Module Reloading

This example shows how to work with module reloading functionality:

  • Importing a module and accessing its initial state
  • Reloading the module to pick up changes
  • Handling reloading errors gracefully
  • Managing module state during reloads

Module reloading

Version-Specific Imports

This example demonstrates handling version-specific module imports:

  • Importing specific versions of modules
  • Managing version compatibility
  • Accessing and verifying version information
  • Working with version-specific features

Version-specific imports

Dependencies and Environment Variables

This example shows how to handle module dependencies and environment requirements:

  • Importing modules with external dependencies
  • Managing required dependency versions
  • Setting up and accessing environment variables
  • Handling environment-specific configurations

Dependencies and environment variables

Advanced Features

This example demonstrates advanced module import capabilities:

  • Using custom module loaders for specialized import scenarios
  • Working with namespace packages
  • Managing entry points
  • Handling complex module configurations

Advanced features