Skip to content
CodeKruPro

Where does a relative path point?

QuizMediumPython only

A test opens open("testdata/users.csv"). It passes when run from the project root but fails from another folder. Which statements are true? Pick all that apply.

  • Relative paths are resolved against the current working directory
  • Relative paths are resolved against the folder of the test file
  • Path(__file__).parent / "testdata" / "users.csv" works from any folder
  • Hard-coding C:\\Users\\me\\project\\testdata is the most portable fix

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in