test: deduplicate datetime index tests (#1460) #1461
      
        
          +0
        
        
          −12
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Description
This PR removes duplicate test code in
test_datetime_index.pyfor DatetimeIndex relational operations.Changes
dt_idxwhenidxalready covered the same casesIssue
Fixes #1460
Rationale
The
idxvariable is created frompd.Index(data, name="date")wheredatais aDatetimeIndex. Sincedatais already a DatetimeIndex,pd.Index(data, name="date")returns aDatetimeIndex. Similarly,dt_idxis created frompd.DatetimeIndex(data, name="date"), which also returns aDatetimeIndex. Both variables are equivalent DatetimeIndex objects, making the duplicate tests redundant.Test Coverage
Remaining tests (lines 29-36): All relational operations are still fully covered:
data[x <= idx]- line 29data[x < idx]- line 30data[x >= idx]- line 31data[x > idx]- line 32data[idx <= x]- line 33data[idx < x]- line 34data[idx >= x]- line 35data[idx > x]- line 36The removed tests (previously lines 40-48) were identical duplicates using
dt_idxinstead ofidx. Since bothidxanddt_idxareDatetimeIndexobjects with the same data, all 8 relational operation combinations remain fully tested.Testing
python3 -m py_compile tests/indexes/test_datetime_index.pyidxChecklist