1414# limitations under the License.
1515import argparse
1616import logging
17- import os .path
18- import textwrap
1917
2018import pytest
2119
@@ -29,22 +27,18 @@ def test_settings_takes_no_positional_arguments():
2927 settings .Settings ("a" , "b" , "c" )
3028
3129
32- def test_settings_transforms_repository_config (tmpdir ):
30+ def test_settings_transforms_repository_config (write_config_file ):
3331 """Set repository config and defaults when .pypirc is provided."""
34- pypirc = os .path .join (str (tmpdir ), ".pypirc" )
35-
36- with open (pypirc , "w" ) as fp :
37- fp .write (
38- textwrap .dedent (
39- """
40- [pypi]
41- repository: https://upload.pypi.org/legacy/
42- username:username
43- password:password
32+ config_file = write_config_file (
4433 """
45- )
46- )
47- s = settings .Settings (config_file = pypirc )
34+ [pypi]
35+ repository: https://upload.pypi.org/legacy/
36+ username:username
37+ password:password
38+ """
39+ )
40+
41+ s = settings .Settings (config_file = config_file )
4842 assert s .repository_config ["repository" ] == "https://upload.pypi.org/legacy/"
4943 assert s .sign is False
5044 assert s .sign_with == "gpg"
@@ -72,16 +66,14 @@ def test_setup_logging(verbose, log_level):
7266 "verbose" ,
7367 [True , False ],
7468)
75- def test_print_config_path_if_verbose (tmpdir , capsys , make_settings , verbose ):
69+ def test_print_config_path_if_verbose (config_file , capsys , make_settings , verbose ):
7670 """Print the location of the .pypirc config used by the user."""
77- pypirc = os .path .join (str (tmpdir ), ".pypirc" )
78-
7971 make_settings (verbose = verbose )
8072
8173 captured = capsys .readouterr ()
8274
8375 if verbose :
84- assert captured .out == f"Using configuration from { pypirc } \n "
76+ assert captured .out == f"Using configuration from { config_file } \n "
8577 else :
8678 assert captured .out == ""
8779
0 commit comments