Skip to content

Commit f3fd656

Browse files
committed
Add basic test for gibberish detector #2402
Signed-off-by: Jono Yang <[email protected]>
1 parent 21b7450 commit f3fd656

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/textcode/test_gibberish.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
from commoncode.testcase import FileBasedTesting
11+
12+
from textcode import gibberish
13+
14+
15+
class TestGibberish(FileBasedTesting):
16+
def test_gibberish_basic(self):
17+
# From https://github.com/rrenaud/Gibberish-Detector/blob/847d95ad706b535199b90b4d44e4e6e80564e379/README.rst#usage
18+
g = gibberish.Gibberish()
19+
self.assertFalse(g.detect_gibberish("my name is rob and i like to hack"))
20+
self.assertFalse(g.detect_gibberish("is this thing working?"))
21+
self.assertFalse(g.detect_gibberish("i hope so"))
22+
self.assertTrue(g.detect_gibberish("t2 chhsdfitoixcv"))
23+
self.assertTrue(g.detect_gibberish("ytjkacvzw"))
24+
self.assertTrue(g.detect_gibberish("yutthasxcvqer"))
25+
self.assertFalse(g.detect_gibberish("seems okay"))
26+
self.assertFalse(g.detect_gibberish("yay!"))

0 commit comments

Comments
 (0)