Skip to content

Commit da5777a

Browse files
authored
Use assert_eq! and assert_ne! where relevant (#5547)
1 parent e3e24cc commit da5777a

File tree

13 files changed

+33
-33
lines changed

13 files changed

+33
-33
lines changed

pyo3-build-config/src/impl_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ fn escape(bytes: &[u8]) -> String {
19981998
}
19991999

20002000
fn unescape(escaped: &str) -> Vec<u8> {
2001-
assert!(escaped.len() % 2 == 0, "invalid hex encoding");
2001+
assert_eq!(escaped.len() % 2, 0, "invalid hex encoding");
20022002

20032003
let mut bytes = Vec::with_capacity(escaped.len() / 2);
20042004

src/conversions/hashbrown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ mod tests {
158158

159159
let py_map = (&map).into_pyobject(py).unwrap();
160160

161-
assert!(py_map.len() == 1);
161+
assert_eq!(py_map.len(), 1);
162162
assert!(
163163
py_map
164164
.get_item(1)

src/conversions/indexmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod test_indexmap {
165165

166166
let py_map = (&map).into_pyobject(py).unwrap();
167167

168-
assert!(py_map.len() == 1);
168+
assert_eq!(py_map.len(), 1);
169169
assert!(
170170
py_map
171171
.get_item(1)

src/conversions/std/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ mod tests {
183183
.unwrap()
184184
.extract()
185185
.unwrap();
186-
assert!(&v == b"abcabcabcabcabcabcabcabcabcabcabc");
186+
assert_eq!(&v, b"abcabcabcabcabcabcabcabcabcabcabc");
187187
})
188188
}
189189

@@ -213,7 +213,7 @@ mod tests {
213213
.unwrap()
214214
.extract()
215215
.unwrap();
216-
assert!(&v == b"abcabcabcabcabcabcabcabcabcabcabc");
216+
assert_eq!(&v, b"abcabcabcabcabcabcabcabcabcabcabc");
217217
})
218218
}
219219

@@ -225,7 +225,7 @@ mod tests {
225225
.unwrap()
226226
.extract()
227227
.unwrap();
228-
assert!(&v == b"abc");
228+
assert_eq!(&v, b"abc");
229229
});
230230
}
231231
#[test]

src/conversions/std/map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ mod tests {
171171

172172
let py_map = (&map).into_pyobject(py).unwrap();
173173

174-
assert!(py_map.len() == 1);
174+
assert_eq!(py_map.len(), 1);
175175
assert!(
176176
py_map
177177
.get_item(1)
@@ -193,7 +193,7 @@ mod tests {
193193

194194
let py_map = (&map).into_pyobject(py).unwrap();
195195

196-
assert!(py_map.len() == 1);
196+
assert_eq!(py_map.len(), 1);
197197
assert!(
198198
py_map
199199
.get_item(1)
@@ -215,7 +215,7 @@ mod tests {
215215

216216
let py_map = map.into_pyobject(py).unwrap();
217217

218-
assert!(py_map.len() == 1);
218+
assert_eq!(py_map.len(), 1);
219219
assert!(
220220
py_map
221221
.get_item(1)
@@ -236,7 +236,7 @@ mod tests {
236236

237237
let py_map = map.into_pyobject(py).unwrap();
238238

239-
assert!(py_map.len() == 1);
239+
assert_eq!(py_map.len(), 1);
240240
assert!(
241241
py_map
242242
.get_item(1)

src/conversions/std/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod tests {
165165
.unwrap()
166166
.extract()
167167
.unwrap();
168-
assert!(v == [1, 2]);
168+
assert_eq!(v, [1, 2]);
169169
});
170170
}
171171

@@ -177,7 +177,7 @@ mod tests {
177177
.unwrap()
178178
.extract()
179179
.unwrap();
180-
assert!(v == [1, 2, 3, 4]);
180+
assert_eq!(v, [1, 2, 3, 4]);
181181
});
182182
}
183183

@@ -189,7 +189,7 @@ mod tests {
189189
.unwrap()
190190
.extract()
191191
.unwrap();
192-
assert!(v == b"abc");
192+
assert_eq!(v, b"abc");
193193
});
194194
}
195195
}

src/internal/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ mod tests {
504504
Python::attach(|py| {
505505
// Make a simple object with 1 reference
506506
let obj = get_object(py);
507-
assert!(obj.get_refcnt(py) == 1);
507+
assert_eq!(obj.get_refcnt(py), 1);
508508
// Cloning the object when detached should panic
509509
py.detach(|| obj.clone());
510510
});

src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ mod tests {
14671467
Err(poisoned) => poisoned.into_inner(),
14681468
}
14691469
});
1470-
assert!(*guard == 42);
1470+
assert_eq!(*guard, 42);
14711471
}
14721472

14731473
#[cfg(feature = "macros")]
@@ -1699,7 +1699,7 @@ mod tests {
16991699
Python::attach(|py| {
17001700
// recover from the poisoning
17011701
let guard = rwlock.write_py_attached(py).unwrap_err().into_inner();
1702-
assert!(*guard == 42);
1702+
assert_eq!(*guard, 42);
17031703
});
17041704
}
17051705
}

src/types/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ mod tests {
12221222
-5
12231223
});
12241224
assert_eq!(sum, -5);
1225-
assert!(list.len() == 0);
1225+
assert_eq!(list.len(), 0);
12261226
});
12271227
}
12281228

src/types/mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ mod tests {
452452
.join()
453453
});
454454
mutex.clear_poison();
455-
assert!(*mutex.lock().unwrap() == 0);
455+
assert_eq!(*mutex.lock().unwrap(), 0);
456456
}
457457

458458
#[test]

0 commit comments

Comments
 (0)