Skip to content

Commit ce7ca2d

Browse files
committed
set cwd in test so config file can be found
1 parent 9f10e11 commit ce7ca2d

6 files changed

Lines changed: 22 additions & 15 deletions

File tree

docs/source/examples/labpdfprocapp-example.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
8787
8888
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 -c
8989
90-
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
90+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo-cve.chi``.
9191

9292
``labpdfproc zscan`` Command
9393
----------------------------
@@ -125,7 +125,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
125125
126126
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303 -c
127127
128-
This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0_cve.chi``.
128+
This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0-cve.chi``.
129129

130130
``labpdfproc sample`` Command
131131
-----------------------------
@@ -165,7 +165,7 @@ To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
165165
166166
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303 -c
167167
168-
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
168+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo-cve.chi``.
169169

170170
Additional CLI options
171171
----------------------

news/check-saved-files.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* Changed output file behavior to raise an error early if the saved file exists.
88
* Changed saved file name from ``_corrected.chi`` to ``-mud-corrected.chi``.
9+
* Changed saved file name from ``_cve.chi`` to ``-cve.chi``.
910

1011
**Deprecated:**
1112

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _save_corrected(corrected, input_path, args):
138138

139139

140140
def _save_correction(correction, input_path, args):
141-
corrfile = args.output_directory / (input_path.stem + "_cve.chi")
141+
corrfile = args.output_directory / (input_path.stem + "-cve.chi")
142142
correction.metadata = correction.metadata or {}
143143
correction.dump(str(corrfile), xtype=args.xtype)
144144
print(f"Saved correction data to {corrfile}")

src/diffpy/labpdfproc/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def _check_saved_file_exists(args):
537537
if outfile.exists() and not args.force:
538538
existing_files.append(outfile)
539539
if args.output_correction:
540-
corrfile = args.output_directory / (path.stem + "_cve.chi")
540+
corrfile = args.output_directory / (path.stem + "-cve.chi")
541541
if corrfile.exists() and not args.force:
542542
existing_files.append(corrfile)
543543
if existing_files:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def user_filesystem(tmp_path):
6262

6363
with open(output_dir / "good_data-mud-corrected.chi", "w") as f:
6464
f.write(chi_data)
65-
with open(output_dir / "good_data_cve.chi", "w") as f:
65+
with open(output_dir / "good_data-cve.chi", "w") as f:
6666
f.write(chi_data)
6767
home_config_data = {
6868
"wavelength": 0.3,

tests/test_tools.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -849,23 +849,29 @@ def test_load_metadata(mocker, user_filesystem, inputs, expected):
849849
assert actual_metadata == expected_metadata
850850

851851

852-
def test_preprocess_args_bad(user_filesystem):
852+
def test_preprocess_args_bad(user_filesystem, monkeypatch):
853853
# Case: user tries to run absorption correction, but the output
854-
# filenames already for *-mud-corrected.chi and *_cve.chi exists.
854+
# filenames already for *-mud-corrected.chi and *-cve.chi exists.
855855
# expected: preprocess_args catches this early and raises an Error
856+
cwd = Path(user_filesystem)
857+
home_dir = cwd / "home_dir"
858+
# set cwd so program can find diffpyconfig.json
859+
monkeypatch.setattr("pathlib.Path.home", lambda _: home_dir)
856860
input_data_file = str(user_filesystem / "good_data.chi")
857861
existing_corrected_file = str(
858862
user_filesystem / "output_dir" / "good_data-mud-corrected.chi"
859863
)
860864
existing_corrected_cve_file = str(
861-
user_filesystem / "output_dir" / "good_data_cve.chi"
862-
)
863-
cli_inputs = (
864-
["mud"]
865-
+ [input_data_file]
866-
+ ["2.5", "-w", "Mo", "-o", str(user_filesystem / "output_dir")]
867-
+ ["-c"] # -c flag saves the cve file
865+
user_filesystem / "output_dir" / "good_data-cve.chi"
868866
)
867+
cli_inputs = [
868+
"mud",
869+
input_data_file,
870+
"2.5",
871+
"-o",
872+
str(user_filesystem / "output_dir"),
873+
"-c", # -c flag saves the cve file
874+
]
869875
args = get_args_cli(cli_inputs)
870876
args = set_input_lists(args)
871877
msg = (

0 commit comments

Comments
 (0)