Skip to content

Commit 3777e36

Browse files
committed
Add tests for dockerfile paths to ensure backwards compatibility
Signed-off-by: Ethan Paul <[email protected]>
1 parent 3720d4a commit 3777e36

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pytest
1515
import re
1616
import sys
17+
from pathlib import Path
1718
from textwrap import dedent
1819

1920
from dockerfile_parse import DockerfileParser
@@ -1521,3 +1522,18 @@ def test_alt_dockerfile_names(self, tmpdir):
15211522

15221523
validate = DockerfileParser(path=tmpdir, dockerfile_filename="Containerfile")
15231524
assert validate.baseimage == out.baseimage
1525+
1526+
def test_dockerfile_path_compatibility(self, tmpdir):
1527+
tmpdir = Path(tmpdir)
1528+
parser = DockerfileParser(path=tmpdir)
1529+
assert str(parser.dockerfile) == parser.dockerfile_path
1530+
assert parser.dockerfile == tmpdir / "Dockerfile"
1531+
1532+
with (tmpdir / "nothing").open("w+") as testfile:
1533+
nullparser = DockerfileParser(fileobj=testfile)
1534+
assert nullparser.dockerfile is None
1535+
assert nullparser.dockerfile_path is None
1536+
1537+
newfile = tmpdir / "nowhere"
1538+
parser.dockerfile_path = str(newfile)
1539+
assert parser.dockerfile == newfile

0 commit comments

Comments
 (0)