Skip to content

Unit-test string replacement in LREPRSTRUCT test #3325

@samsrabin

Description

@samsrabin

Originally posted by @billsacks in #3314 (comment)

I got as far as thinking about how I'd do this:

  1. Pull replace_grain into a top-level function
  2. Extract the line, user_nl_clm_text = re.sub(r"GRAIN\w*", replace_grain, user_nl_clm_text) into a new top-level function in the module. This will be the function that would be unit tested.
  3. Do a manual test of building the LREPRSTRUCT test to ensure that the user_nl_clm file is still the same as before after steps (1) and (2).
  4. Create a unit test module for LREPRSTRUCT
  5. Create at least one unit test for the extracted function, giving it a string as input and testing the resulting string. At a minimum this should have the situation mentioned in my comment above, where one line contains 'GRAINN_TO_FOOD' and a later line contains (among other things) "'GRAINN_TO_FOOD_PERHARV', 'GRAINN_TO_FOOD_ANN'". (The later line could include a more extensive line that matches what's in that line in the current user_nl_clm.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions