mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-16 07:38:50 +00:00
104 lines
3.5 KiB
Markdown
104 lines
3.5 KiB
Markdown
# Report for Assignment 1 - Group 82
|
|
|
|
## Project Information
|
|
|
|
- **Name:** TheFuck - Magnificent app which corrects your previous console command
|
|
- **URL:** https://github.com/dimalarcon/SEP2024-Group82-thefuck
|
|
- **Programming Language:** Python
|
|
|
|
## Code Metrics
|
|
|
|
- **Number of lines of code:** 547801 (54.7 KLOC)
|
|
- **Tool used to measure the number of lines of code:** lizard
|
|
|
|
.png)
|
|
|
|
## Coverage Measurement
|
|
|
|
- **Existing tool used to measure the coverage:** coverage.py
|
|
- **Coverage result:** 94%
|
|
|
|
.png)
|
|
.png)
|
|
|
|
## Tasks
|
|
|
|
### Luca De Nobili
|
|
|
|
### Function 1 (property): in thefuck/types.py
|
|
|
|
#### 1. Function Instrumentation
|
|
|
|
- **Before instrumentation:**
|
|
|
|

|
|
|
|
- **After instrumentation:**
|
|
|
|

|
|
|
|
#### 2. Coverage Improvement
|
|
|
|
- **Coverage before adding new tests to the corresponding test file: /tests/test_types.py**
|
|
|
|

|
|
|
|
- **Creating new tests to cover the function**
|
|
|
|
```python
|
|
def test_script_parts_exception(self, mocker, caplog):
|
|
mocker.patch('thefuck.shells.shell.split_command', side_effect=Exception('Mocked exception'))
|
|
command = Command('invalid command', 'output')
|
|
|
|
with caplog.at_level('DEBUG'):
|
|
parts = command.script_parts
|
|
assert parts == []
|
|
|
|
print(f"Branch coverage: {sum(branch_coverage.values())/len(branch_coverage) * 100}%\n")
|
|
```
|
|
- **Coverage after adding new tests to the corresponding test file: /tests/types.py**
|
|
|
|
.png)
|
|
|
|
|
|
### Function 2: get_installation_version in thefuck/utils.py
|
|
|
|
#### 1. Function Instrumentation
|
|
|
|
- **Before instrumentation:**
|
|
|
|

|
|
|
|
- **After instrumentation:**
|
|
|
|

|
|
|
|
#### 2. Coverage Improvement
|
|
|
|
- **Coverage before adding new tests to the corresponding test file: /tests/test_utils.py**
|
|
|
|

|
|
|
|
- **Creating new tests to cover the function**
|
|
|
|
```python
|
|
class TestGetInstallationVersion(unittest.TestCase):
|
|
|
|
@patch('importlib.metadata.version', unittest.mock.MagicMock(return_value='1.2.3'))
|
|
def test_get_installation_version_with_importlib(self):
|
|
version = get_installation_version()
|
|
self.assertEqual(version,'1.2.3')
|
|
|
|
@patch('importlib.metadata.version', side_effect=ImportError)
|
|
@patch('pkg_resources.require', return_value=[unittest.mock.MagicMock(version='4.5.6')])
|
|
def test_get_installation_version_with_pkg_resources(self, mock_require, mock_version):
|
|
version = get_installation_version()
|
|
self.assertEqual(version, '4.5.6')
|
|
print(f"Branch coverage: {sum(branch_coverage.values())/len(branch_coverage) * 100}% ")
|
|
|
|
```
|
|
- **Coverage after adding new tests to the corresponding test file: /tests/test_utils.py**
|
|
|
|

|
|
|