Skip to content

Commit cab280b

Browse files
authored
test adult-test: reduce checking (#228)
GitHub: GH-188 Because csv file is too big (16,281 rows). Before this change: ```console $ time ruby test/run-test.rb -t AdultTest::test --verbose=important-only Finished in 1.355024 seconds. 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications real 0m1.980s user 0m1.777s sys 0m0.113s ``` After this change: ```console $ time ruby test/run-test.rb -t AdultTest::test --verbose=important-only Finished in 0.002213 seconds. 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications real 0m0.619s user 0m0.442s sys 0m0.089s ```
1 parent 7f4212b commit cab280b

File tree

1 file changed

+18
-43
lines changed

1 file changed

+18
-43
lines changed

test/test-adult.rb

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,24 @@ def record(*args)
4040
end
4141

4242
test("#each") do
43-
records = @dataset.each.to_a
44-
assert_equal([
45-
16281,
46-
{
47-
:age => 25,
48-
:work_class => "Private",
49-
:final_weight => 226802,
50-
:education => "11th",
51-
:n_education_years => 7,
52-
:marital_status => "Never-married",
53-
:occupation => "Machine-op-inspct",
54-
:relationship => "Own-child",
55-
:race => "Black",
56-
:sex => "Male",
57-
:capital_gain => 0,
58-
:capital_loss => 0,
59-
:hours_per_week => 40,
60-
:native_country => "United-States",
61-
:label => "<=50K."
62-
},
63-
{
64-
:age => 35,
65-
:work_class => "Self-emp-inc",
66-
:final_weight => 182148,
67-
:education => "Bachelors",
68-
:n_education_years => 13,
69-
:marital_status => "Married-civ-spouse",
70-
:occupation => "Exec-managerial",
71-
:relationship => "Husband",
72-
:race => "White",
73-
:sex => "Male",
74-
:capital_gain => 0,
75-
:capital_loss => 0,
76-
:hours_per_week => 60,
77-
:native_country => "United-States",
78-
:label => ">50K."
79-
}
80-
],
81-
[
82-
records.size,
83-
records[0].to_h,
84-
records[-1].to_h
85-
])
43+
assert_equal({
44+
:age => 25,
45+
:work_class => "Private",
46+
:final_weight => 226802,
47+
:education => "11th",
48+
:n_education_years => 7,
49+
:marital_status => "Never-married",
50+
:occupation => "Machine-op-inspct",
51+
:relationship => "Own-child",
52+
:race => "Black",
53+
:sex => "Male",
54+
:capital_gain => 0,
55+
:capital_loss => 0,
56+
:hours_per_week => 40,
57+
:native_country => "United-States",
58+
:label => "<=50K.",
59+
},
60+
@dataset.each.next.to_h)
8661
end
8762
end
8863

0 commit comments

Comments
 (0)