Skip to content

Commit 2362942

Browse files
Extended test cases
1 parent 89b7e90 commit 2362942

File tree

7 files changed

+2361
-0
lines changed

7 files changed

+2361
-0
lines changed
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
# Unit Testing Extension - README
2+
3+
## Overview
4+
5+
This document explains how to run the 15 additional unit test cases added to the pandas codebase as part of our SWEN 777 course project. These tests target critical edge cases and uncovered logic paths across three key pandas modules.
6+
7+
**Project Details:**
8+
- **Course:** SWEN 777 - Software Architecture
9+
- **Group Size:** 3 members
10+
- **Deliverable:** 15 meaningful unit test cases (5 per student)
11+
- **Target:** Increase test coverage for uncovered or edge-case logic
12+
13+
## Test Files Overview
14+
15+
Our group added tests to three separate files to avoid interfering with the baseline test suite:
16+
17+
1. **`pandas/tests/test_nanops_additional.py`** (NEW FILE)
18+
- 5 tests for numerical operations edge cases
19+
- Tests empty arrays, mask scenarios, boundary conditions
20+
21+
2. **`pandas/tests/test_series_constructors_additional.py`** (NEW FILE)
22+
- 5 tests for Series object creation edge cases
23+
- Tests invalid inputs, empty data, dtype inference
24+
25+
3. **`pandas/tests/tseries/offsets/test_offsets.py`** (MODIFIED FILE)
26+
- 5 tests for datetime offset edge cases (added to existing file)
27+
- Tests boundary timestamps, business logic, leap years
28+
29+
## How to Reproduce Test Results
30+
31+
### Prerequisites
32+
33+
Before running the tests, ensure you have:
34+
- Python 3.13+ installed
35+
- Virtual environment activated
36+
- pandas development version (3.0.0.dev0+)
37+
- pytest 8.4.2+ with pytest-cov 7.0.0+
38+
39+
### Step-by-Step Instructions
40+
41+
#### 1. Environment Setup
42+
```bash
43+
# Navigate to project directory
44+
cd /Volumes/T7Shield/SWEN777/SWEN_777_Pandas
45+
46+
# Activate virtual environment
47+
source venv/bin/activate
48+
```
49+
50+
#### 2. Run All 15 Added Tests
51+
```bash
52+
python -m pytest \
53+
pandas/tests/test_nanops_additional.py \
54+
pandas/tests/test_series_constructors_additional.py \
55+
pandas/tests/tseries/offsets/test_offsets.py::test_dateoffset_boundary_values \
56+
pandas/tests/tseries/offsets/test_offsets.py::test_business_day_weekend_edge_cases \
57+
pandas/tests/tseries/offsets/test_offsets.py::test_custom_business_hour_edge_cases \
58+
pandas/tests/tseries/offsets/test_offsets.py::test_quarter_offset_leap_year \
59+
pandas/tests/tseries/offsets/test_offsets.py::test_offset_frequency_string_edge_cases \
60+
-v
61+
```
62+
63+
#### 3. Generate Coverage Report
64+
```bash
65+
python -m pytest \
66+
pandas/tests/test_nanops_additional.py \
67+
pandas/tests/test_series_constructors_additional.py \
68+
pandas/tests/tseries/offsets/test_offsets.py::test_dateoffset_boundary_values \
69+
pandas/tests/tseries/offsets/test_offsets.py::test_business_day_weekend_edge_cases \
70+
pandas/tests/tseries/offsets/test_offsets.py::test_custom_business_hour_edge_cases \
71+
pandas/tests/tseries/offsets/test_offsets.py::test_quarter_offset_leap_year \
72+
pandas/tests/tseries/offsets/test_offsets.py::test_offset_frequency_string_edge_cases \
73+
--cov=pandas --cov-report=html:courseProjectDocs/Setup/htmlcov --cov-report=term
74+
```
75+
76+
#### 4. Run Tests by Category (Optional)
77+
78+
**Nanops Tests Only:**
79+
```bash
80+
python -m pytest pandas/tests/test_nanops_additional.py -v
81+
```
82+
83+
**Series Constructor Tests Only:**
84+
```bash
85+
python -m pytest pandas/tests/test_series_constructors_additional.py -v
86+
```
87+
88+
**DateTime Offset Tests Only:**
89+
```bash
90+
python -m pytest \
91+
pandas/tests/tseries/offsets/test_offsets.py::test_dateoffset_boundary_values \
92+
pandas/tests/tseries/offsets/test_offsets.py::test_business_day_weekend_edge_cases \
93+
pandas/tests/tseries/offsets/test_offsets.py::test_custom_business_hour_edge_cases \
94+
pandas/tests/tseries/offsets/test_offsets.py::test_quarter_offset_leap_year \
95+
pandas/tests/tseries/offsets/test_offsets.py::test_offset_frequency_string_edge_cases \
96+
-v
97+
```
98+
99+
## Expected Test Results
100+
101+
When you run the tests, you should see:
102+
103+
- **Total Tests:** 15
104+
- **Tests Passed:** 15
105+
- **Tests Failed:** 0
106+
- **Success Rate:** 100%
107+
- **Execution Time:** ~1.04 seconds
108+
109+
**Sample Output:**
110+
```
111+
============================= test session starts ==============================
112+
platform darwin -- Python 3.13.5, pytest-8.4.2, pluggy-1.6.0
113+
collected 15 items
114+
115+
pandas/tests/test_nanops_additional.py::test_nansum_empty_array_edge_cases PASSED
116+
pandas/tests/test_nanops_additional.py::test_nanmean_mask_edge_cases PASSED
117+
pandas/tests/test_nanops_additional.py::test_nanvar_ddof_boundary_conditions PASSED
118+
pandas/tests/test_nanops_additional.py::test_nanargmax_nanargmin_error_conditions PASSED
119+
pandas/tests/test_nanops_additional.py::test_nanskew_nankurt_insufficient_samples PASSED
120+
pandas/tests/test_series_constructors_additional.py::test_series_constructor_invalid_key_types PASSED [ 7%]
121+
pandas/tests/test_series_constructors_additional.py::test_series_constructor_empty_edge_cases PASSED [ 8%]
122+
pandas/tests/test_series_constructors_additional.py::test_series_constructor_mixed_dtype_edge_cases PASSED [ 9%]
123+
pandas/tests/test_series_constructors_additional.py::test_series_constructor_memory_intensive PASSED [ 10%]
124+
pandas/tests/test_series_constructors_additional.py::test_series_constructor_invalid_index_length PASSED [ 11%]
125+
pandas/tests/tseries/offsets/test_offsets.py::test_dateoffset_boundary_values PASSED [ 12%]
126+
pandas/tests/tseries/offsets/test_offsets.py::test_business_day_weekend_edge_cases PASSED [ 13%]
127+
pandas/tests/tseries/offsets/test_offsets.py::test_custom_business_hour_edge_cases PASSED [ 14%]
128+
pandas/tests/tseries/offsets/test_offsets.py::test_quarter_offset_leap_year PASSED [ 15%]
129+
pandas/tests/tseries/offsets/test_offsets.py::test_offset_frequency_string_edge_cases PASSED [ 16%]
130+
131+
============================== 15 passed in 1.04s ==============================
132+
```
133+
134+
## Coverage Analysis
135+
136+
### Comprehensive Coverage Command
137+
To run both baseline and additional tests for complete coverage analysis:
138+
139+
```bash
140+
python -m pytest \
141+
pandas/tests/series/test_constructors.py \
142+
pandas/tests/frame/test_constructors.py \
143+
pandas/tests/test_nanops.py \
144+
pandas/tests/series/methods/test_dropna.py \
145+
pandas/tests/frame/methods/test_dropna.py \
146+
pandas/tests/test_nanops_additional.py \
147+
pandas/tests/test_series_constructors_additional.py \
148+
pandas/tests/tseries/offsets/test_offsets.py::test_dateoffset_boundary_values \
149+
pandas/tests/tseries/offsets/test_offsets.py::test_business_day_weekend_edge_cases \
150+
pandas/tests/tseries/offsets/test_offsets.py::test_custom_business_hour_edge_cases \
151+
pandas/tests/tseries/offsets/test_offsets.py::test_quarter_offset_leap_year \
152+
pandas/tests/tseries/offsets/test_offsets.py::test_offset_frequency_string_edge_cases \
153+
--cov=pandas --cov-report=html:courseProjectDocs/Setup/htmlcov --cov-report=term
154+
```
155+
156+
### Coverage Report Location
157+
- **HTML Report:** `courseProjectDocs/Setup/htmlcov/index.html`
158+
- **Terminal Output:** Displayed during test execution
159+
- **Expected Coverage:** 11% overall (improvement from ~10% baseline)
160+
161+
## Troubleshooting
162+
163+
### Common Issues and Solutions
164+
165+
1. **Environment Setup**
166+
- Ensure virtual environment is activated
167+
- Verify Python 3.13+ installation
168+
- Check pandas development build installation
169+
170+
2. **Test Execution Problems**
171+
- Clear pytest cache: `python -m pytest --cache-clear`
172+
- Run tests individually if batch execution fails
173+
- Check for import conflicts
174+
175+
3. **Coverage Report Issues**
176+
- Ensure output directory exists: `mkdir -p courseProjectDocs/Setup/htmlcov`
177+
- Run with verbose output: `--cov-report=term-missing`
178+
179+
180+
181+
## Project Team Information
182+
183+
**Course:** SWEN 777 - Software Testing and Quality Assurance
184+
**Project:** Pandas Unit Testing Extension
185+
**Team Members:**
186+
- Nithikesh Reddy
187+
- Sandeep
188+
- Malikarjuna
189+
190+
191+
## Results
192+
193+
- **Test Execution:** All 15 tests should pass
194+
- **Coverage Improvement:** From ~10% to 11% overall coverage
195+
- **New Code Coverage:** 100% coverage for added test functions
196+
- pytest-cov 7.0.0+ (for coverage analysis)
197+
- numpy
198+
- Virtual environment recommended
199+
200+
## Setting Up Test Environment
201+
202+
1. Create and activate a virtual environment
203+
2. Install development dependencies from requirements-dev.txt
204+
3. Build pandas in development mode
205+
206+
## Coverage Analysis
207+
208+
To analyze coverage improvements from these tests, use pytest with coverage flags targeting the specific modules (pandas.core.nanops, pandas.core.series, pandas.tseries.offsets) and generate both HTML and terminal reports.
209+
210+
## Test Design Principles
211+
All added tests follow these principles:
212+
1. **Edge Case Focus:** Target boundary conditions and unusual inputs
213+
2. **Error Handling:** Test exception conditions and error paths
214+
3. **Uncovered Logic:** Address gaps identified in coverage analysis
215+
4. **Maintainability:** Clear naming and comprehensive documentation
216+
5. **Integration:** Seamlessly integrate with existing test structure
217+
218+
## Files Modified
219+
220+
1. `pandas/tests/test_nanops.py` - Added 5 test functions (lines ~1280-1340)
221+
2. `pandas/tests/series/test_constructors.py` - Added 5 test functions (lines ~890-970)
222+
3. `pandas/tests/tseries/offsets/test_offsets.py` - Added 5 test functions (lines ~1235-1310)
223+
224+
## Group Members
225+
226+
- Member 1: Nanops module test cases (5 tests)
227+
- Member 2: Series constructor test cases (5 tests)
228+
- Member 3: DateTime offset test cases (5 tests)
229+
230+
## Success Criteria
231+
All 15 test cases pass successfully
232+
Tests cover edge cases and boundary conditions
233+
Tests integrate with existing pandas test suite
234+
Comprehensive documentation provided
235+
Test cases target previously uncovered code paths
236+
237+
## Next Steps
238+
239+
For further test development:
240+
1. Monitor coverage reports to identify additional gaps
241+
2. Consider adding integration tests for cross-module functionality
242+
3. Expand boundary condition testing for other pandas modules
243+
4. Add performance benchmarks for edge case scenarios

0 commit comments

Comments
 (0)