Skip to content

feat: tests demonstrating copy file interfaces #852

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rhoban13
Copy link
Contributor

@rhoban13 rhoban13 commented Jul 28, 2025

In #676 for copying to/from DockerContainer, it was suggested that we should clarify the interface & usage a bit before proceeding. This PR aims to push that conversation forward with some test cases illustrating proposed usages. Although here I created a Transferable object, in most cases there's no need for the caller to explicitly construct a Transferable, just pass the bytes | Path

Proposed use cases:

  1. Copy into a container by passing a Transferrable into the initializer:
DockerContainer(... transferrables=(Transferrable(source, destination_in_container), ...)
  1. Copy into the container via the builder pattern, prior to starting the container:
DockerContainer(...)
     .with_copy_into_container(b"some_bytes", destination_in_container)
     .with_copy_into_container(some_path, destination_in_container)
  1. Copy into the container at runtime:
with DockerContainer(...) as container:
    container.copy_into_container(b"some_bytes", destination_in_container)
    container.copy_into_container(some_path, destination_in_container)

Note: I've omitted tests where the source or destination is a directory. These should be added after the above use cases are flushed out.

@rhoban13 rhoban13 changed the title Tests demonstrating copy file interfaces feat: tests demonstrating copy file interfaces Jul 28, 2025
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@d40473f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
core/testcontainers/core/container.py 94.73% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #852   +/-   ##
=======================================
  Coverage        ?   85.08%           
=======================================
  Files           ?       14           
  Lines           ?      798           
  Branches        ?      131           
=======================================
  Hits            ?      679           
  Misses          ?       89           
  Partials        ?       30           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant