https://github.com/danedens/py_function_test_generator
Creates a file called "tests.py" with a call to all classes and functions found in the project. the list is only meant to serve as a starting place for writing your tests
https://github.com/danedens/py_function_test_generator
Last synced: about 1 year ago
JSON representation
Creates a file called "tests.py" with a call to all classes and functions found in the project. the list is only meant to serve as a starting place for writing your tests
- Host: GitHub
- URL: https://github.com/danedens/py_function_test_generator
- Owner: DanEdens
- Created: 2023-01-06T19:13:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T19:17:37.000Z (over 3 years ago)
- Last Synced: 2025-02-10T02:41:23.540Z (over 1 year ago)
- Language: Python
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Project Name
------------
This project is a tool for finding and modifying lines in Python files that contain the strings "def" or "class", and writing the modified lines to a file.
This readme was generated by AI and may be inaccurate, Updates will follow shortly
Requirements
------------
- Python 3.6 or higher
- The `os`, `fnmatch`, and `re` modules
Usage
-----
To use the tool, run the `main.py` script with Python:
python UnitTests.py
This will search for all Python files in the parent folder of the current folder, and find all lines that contain the strings "def" or "class". The tool will then remove any instances of the strings "self" and " -> WebElement" from the lines, and write the modified lines to the file `tests.py`. If the file `tests.py` doesn't exist, it will be created.
The tool will overwrite the contents of the `tests.py` file if it already exists. If you want to append the modified lines to the end of the file instead of overwriting it, you can modify the `write_results` function in the `main.py` script to open the file in append mode instead of write mode.
```python
def write_results(modified_strings):
# Open the file in append mode
with open('tests.py', 'a') as f:
# Iterate through the modified strings
for s in modified_strings:
# Write the string to the file followed by a newline character
f.write(s + '\n')