Skip to content

Commit

Permalink
Add tests for dockerfile paths to ensure backwards compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Paul <[email protected]>
  • Loading branch information
enpaul committed Oct 3, 2023
1 parent 0fc3fc3 commit c658544
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest
import re
import sys
from pathlib import Path
from textwrap import dedent

from dockerfile_parse import DockerfileParser
Expand Down Expand Up @@ -1521,3 +1522,18 @@ def test_alt_dockerfile_names(self, tmpdir):

validate = DockerfileParser(path=tmpdir, dockerfile_filename="Containerfile")
assert validate.baseimage == out.baseimage

def test_dockerfile_path_compatibility(self, tmpdir):
tmpdir = Path(tmpdir)
parser = DockerfileParser(path=tmpdir)
assert str(parser.dockerfile) == parser.dockerfile_path
assert parser.dockerfile == tmpdir / "Dockerfile"

with (tmpdir / "nothing").open("w+") as testfile:
nullparser = DockerfileParser(fileobj=testfile)
assert nullparser.dockerfile is None
assert nullparser.dockerfile_path is None

newfile = tmpdir / "nowhere"
parser.dockerfile_path = str(newfile)
assert parser.dockerfile == newfile

0 comments on commit c658544

Please sign in to comment.