<commit_before>(import 
 [hy.models.list [HyList]]
 [hy.models.symbol [HySymbol]]
 )

(defun maptests [tests]
  (HyList
   (map
    (lambda [test]
      (quasiquote
       [(unquote (get test "name"))
	(fn [self]
	  (unquote (get test "expr"))
	  )]
       )
      )
    tests
    )
   )
  )

(defun nametests [tests]
  (HyList
   (map
    (lambda [test]
      (quasiquote
       (
	(unquote (get test "name"))
	)
       )
      )
    tests
    )
   )
  )

(defun buildmodule [tests loader]
  (HyList
   (+
    tests
    [loader]
    )
   )
  )

(defmacro defsuite [name &rest test-exprs]
  (let [[tests (map (lambda [test] (eval test)) test-exprs)]]
    (quasiquote
     (defclass (unquote name) [unittest.TestCase]
       (unquote (maptests tests))
       )
     )
    )
  )

(defmacro defsetup [expr]
  (quasiquote
   {"name" (quote setUp)
	   "expr" (quote (unquote expr))
	   }
   )
  )

(defmacro defteardown [expr]
  (quasiquote
   {"name" (quote tearDown)
	   "expr" (quote (unquote expr))
	   }
   )
  )

(defmacro deftest [name expr]
  (quasiquote
   {
    "name" (quote (unquote name))
	   "expr" (quote (unquote expr))
	   })
  )

(defmacro hytest-main []
  (quote
   (do
    (defclass LocalModule [object]
      [[--init--
	(fn [self dir locals globals]
	  (setattr self "_dir" dir)
	  (setattr self "_locals" locals)
	  (setattr self "_globals" globals)
	  )]

       [--dir--
	(fn [self]
	  (getattr self "_dir")
	  )]

       [--getattr--
	(fn [self attr]
	  (.get (getattr self "_locals") attr 
		(.get (getattr self "_globals") attr None)
		)
	  )]
       ])
    (unittest.main (LocalModule (dir) (locals) (globals)))<commit_msg>Some cleanup for attribute access, and removing an unused module<commit_after>(import 
 [hy.models.list [HyList]]
 )

(defun maptests [tests]
  (HyList
   (map
    (lambda [test]
      (quasiquote
       [(unquote (get test "name"))
	(fn [self]
	  (unquote (get test "expr"))
	  )]
       )
      )
    tests
    )
   )
  )

(defun nametests [tests]
  (HyList
   (map
    (lambda [test]
      (quasiquote
       (
	(unquote (get test "name"))
	)
       )
      )
    tests
    )
   )
  )

(defun buildmodule [tests loader]
  (HyList
   (+
    tests
    [loader]
    )
   )
  )

(defmacro defsuite [name &rest test-exprs]
  (let [[tests (map (lambda [test] (eval test)) test-exprs)]]
    (quasiquote
     (defclass (unquote name) [unittest.TestCase]
       (unquote (maptests tests))
       )
     )
    )
  )

(defmacro defsetup [expr]
  (quasiquote
   {"name" (quote setUp)
	   "expr" (quote (unquote expr))
	   }
   )
  )

(defmacro defteardown [expr]
  (quasiquote
   {"name" (quote tearDown)
	   "expr" (quote (unquote expr))
	   }
   )
  )

(defmacro deftest [name expr]
  (quasiquote
   {
    "name" (quote (unquote name))
	   "expr" (quote (unquote expr))
	   })
  )

(defmacro hytest-main []
  (quote
   (do
    (defclass LocalModule [object]
      [[--init--
	(fn [self dir locals globals]
	  (setattr self "_dir" dir)
	  (setattr self "_locals" locals)
	  (setattr self "_globals" globals)
	  )]

       [--dir--
	(fn [self]
	  (getattr self "_dir")
	  )]

       [--getattr--
	(fn [self attr]
	  (or
	   (.get (getattr self "_locals") attr)
	   (.get (getattr self "_globals") attr)
	   )
	  )]
       ])
    (unittest.main (LocalModule (dir) (locals) (globals)))
{'fraction_non_alphanumeric': 0.15266485998193316, 'fraction_numerical': 0.0, 'mean_word_length': 2.1942307692307694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1390502', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1281, 'n_words': 308}